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

2014/12/9

Trying to let a bullet fly in a correct angle

1
2
UNDEAD_DC UNDEAD_DC

2015/1/6

#
danpost wrote...
You need to declare the double values outside the method so the value is retained between act cycles. Then you need to set their initial values using your lines 11 and 12 (minus the declared types) in the addedToWorld method. Setting their initial values cannot be accomplished until the actor is added into the world (so, the constructor is ruled out as a place to put that code) and you only want to set their initial values once (so, the act method is ruled out as a place to put that code). From then on, you will be adjusting those values by adding the results of lines 18 and 19 (continuous action goes in the act method).
im sorry i dont get it:( can you please give me an example? and why is it working in my tank but not in the bullet? its the same code used in the same way...
xFabi xFabi

2015/1/6

#
Dan said you only want to set those values once If this is true, you can't put them into the method, because act() gets called forever, and so the values would be set over and over
You need to login to post a reply.
1
2