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

3 days ago

how to add more time when you pick up a item

dragnslayer dragnslayer

3 days ago

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

3 days ago

#
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

3 days ago

#
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

3 days ago

#
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.