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

2022/5/21

i need held with my code

truck_hunt97 truck_hunt97

2022/5/21

#
hello I would like help so that when the character catches that ball it increases its speed thanks in advance
private void recoleccionBola()
    {   
        if(isTouching(Bola.class))
        {
            
            removeTouching(Bola.class);
            
        }
    }
Spock47 Spock47

2022/5/21

#
You can use an attribute for the speed and increase it when the ball is touched. And wherever you move, you use the speed attribute:
class MyActor extends Actor
{
    ...
    private int speed = 1;
    ....
        // source code where the actor moves, e.g. within act method
        if (Greenfoot.isKeyDown("s"))
        {
            move(speed);
        }
    ...
    private void recoleccionBola()
    {
        if(isTouching(Bola.class))
        {
            removeTouching(Bola.class);
            speed += 2; // increase speed
        }
    }
    ...
}
truck_hunt97 truck_hunt97

2022/5/21

#
I have a coin counter, every time I take one, this is the account, how do I multiply its value?
danpost danpost

2022/5/25

#
truck_hunt97 wrote...
I have a coin counter, every time I take one, this is the account, how do I multiply its value?
Show all methods and fields that deal with the coin counter and indicate the classes each code block/field is in.
You need to login to post a reply.