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

2012/4/6

incresing varible

-nic- -nic-

2012/4/6

#
im cant figure out how to make a incresing varible this is what i have public void act() { int incresingturn = (incresingturn + 3 ); turn (incresingturn); }
SPower SPower

2012/4/6

#
maybe you have to say:
int incresingturn += 3;
setRotation(getRotation() + incresingturn);
I don't know this works or not, but it's never bad to give it a try.
-nic- -nic-

2012/4/6

#
well i sorta got it to work= public void act() { if (Greenfoot.getRandomNumber(100) <40) { setRotation((getRotation()+5)); } move(3); }
SPower SPower

2012/4/6

#
This is something really different than you showed in your first comment... Doesn't matter :)
-nic- -nic-

2012/4/6

#
i know but i got a bit annoyed
ttamasu ttamasu

2012/4/6

#
Your original post: public void act() { int incresingturn = (incresingturn + 3 ); turn (incresingturn); } If you look at this code you have used a local variable in act() what this means that every time you go into act incrsingturn is reinitialize by default to zero. so you will always get 3. You neeed to make it a class instance variable which means you should delete the declation int int incresingturn = (incresingturn + 3 ); from act () method and place int incresingturn; underneath your other instance variables like MyClass{ int incresingturn; int someOtherVariable; ...... and in the Act method just call your c;lass instance method like so; incresingturn = (incresingturn + 3 ); // notice no "int" so no local variable cheers Takashi
-nic- -nic-

2012/4/6

#
gulp thx i have a look
You need to login to post a reply.