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

2013/3/29

moving and turning objects

6
7
8
9
danpost danpost

2013/3/31

#
But, line 10 of the method has the timer decrementing when the power-up is active.
Gingervitis Gingervitis

2013/3/31

#
I guess it wasn't working. I switched lines 9 and 10 and then it worked. It is always decrementing now but that is fine because when I get the power-up it resets to 200.
danpost danpost

2013/3/31

#
What code do you have for your 'isdp2PoweredUp' method?
Gingervitis Gingervitis

2013/3/31

#
public boolean isdp2PoweredUp()  
    {  
        return (dpPowerUp != null && dpPowerUp.getWorld() != null);        
    }
danpost danpost

2013/3/31

#
I see what is going on, we are not adding a powered-up object into the world for 'dpPowerUp' to reference. Maybe the method should be written as follows:
public boolean isdp2PoweredUp()
{
    return timer3 > 0;
}
danpost danpost

2013/3/31

#
And now, I see there is another method in the class called 'dp2Powered' which does exactly that which I changed 'isdp2PoweredUp' to. Remove the 'isdp2PoweredUp' method and call the 'dp2Powered' method in line 9 of the 'ifCanSeeDP2' method for the 'if' condition.
Gingervitis Gingervitis

2013/3/31

#
the dp2Powered method is exactly what your previous code says. Should I still change 'isdpPoweredUp'?
danpost danpost

2013/3/31

#
First, switch lines 9 and 10 back to the way I posted the 'ifCanSeeDP2' method. Then, you should delete one of the two methods ('isdpPoweredUp' or 'dpPowered') and have the 'if' statement at line 9 of the 'ifCanSeeDP2' method use the one you are keeping. The method you are keeping should have only the following one statement in it:
return timer3 > 0;
Gingervitis Gingervitis

2013/3/31

#
Okay. I switched to what you told me and it is perfect! Thank you!
You need to login to post a reply.
6
7
8
9