So i have this frog that eats bugs but when it eats a certain kind of bug i want the frog to move slower/faster depending on the bug it ate. I only want this "power" to last a few seconds but i cant make the frog move at different speeds and also i dont know how to make it last a few seconds. This is inside the frog class
and it returns the int to my level class
public int foundBug() { Actor bug = getOneObjectAtOffset(0, 0, Bug.class); if(bug != null) { Actor bug1 = getOneObjectAtOffset(0, 0, DoubleBug.class); Actor bug2 = getOneObjectAtOffset(0, 0, FastBug.class); Actor bug3 = getOneObjectAtOffset(0, 0, SlowBug.class); if(bug1!=null) { World myWorld = getWorld(); getWorld().removeObject(bug1); return 1; } if(bug2!=null) { World myWorld = getWorld(); getWorld().removeObject(bug2); return 2; } if(bug3!=null) { World myWorld = getWorld(); getWorld().removeObject(bug2); return 3; } return 0; } else { return -1; } }
public void act() { if(frog.foundBug()==1) { } if(frog.foundBug()==2) { frog.setSpeed(5); } if(frog.foundBug()==3) { frog.setSpeed(1); } else if (frog.foundBug()==0) { frog.speed=3; } }