This site requires JavaScript, please enable it in your browser!
Greenfoot back
dragnslayer
dragnslayer wrote ...

2019/9/12

how to add more time when you pick up a item

dragnslayer dragnslayer

2019/9/12

#
i want to know how you can get more time. when you move over a item.
danpost danpost

2019/9/12

#
dragnslayer wrote...
how to add more time when you pick up a item i want to know how you can get more time. when you move over a item.
Show class where "time" is. Show class of "you". Show class of "item". Show attempted code to add time. "you move over" is not the same as "you pick up" -- attempted code should clarify.
dragnslayer dragnslayer

2019/9/12

#
pick up :
Actor pizza = getOneIntersectingObject(Pizza.class);
        if(pizza!=null)
        {
            World myWorld = getWorld();
            myWorld.removeObject (pizza);
            Rivets rivets = (Rivets)myWorld;
            Counter counter = rivets.getCounter();
            counter.addScore();
        }
        
timer:
int timer= 0;
    public void act() 
    {
        if (timer== (900))
      {
      getWorld().addObject(new Gameover(), 350, 250);
      Greenfoot.stop();
      } 
      addTimer();
    }
    private void addTimer()
    {
        timer++;
    }
danpost danpost

2019/9/12

#
Apparently, you need to subtract from the timer to increase game time (which is what I presume you want to do). There is insufficient information to help any further.
You need to login to post a reply.