Can't figure out what's wrong here (variables)
Monkey Forums/Monkey Programming/Can't figure out what's wrong here (variables)
| ||
Hello. I have a generic class with different methods for movements along x and y coordinates. Then i have a specific class that extend the base one:this class choose movements based on a variable. Once i assign a movement it seems i can't change the variable so it can start another movement once the old one is finished (i think the problem is here..how can i tell when it's actually finished?) These are the 3 generic methods for movement: Here is the update that should swap between movements: I suspect the error is in the last method...but i can't figure out how to tell the method to change movement... |
| ||
Without complete code it's a guessing game. Have you checked if posx ever equals t? t is defaulting to an Int. Is posx a Float by any chance? |
| ||
I found it out...i forgot to set all the variables float! |
| ||
Basically i was comparing and int to a float.silly me. I guess its time to start programming using strict! |
| ||
Thanks for pointing me to it (sorry for spamming the reply! just realised i haven't said thank you). |
| ||
I actually learnt something decent out of it (apart from coding in strict!): i can return a value when the condition inside the method is true so i can play with different status changes (if it make any sense). |