Need help with character movement engine in flash cs4 with as2.0 thanks :)?
-
Whats wrong? onClipEvent(load){ rightspeed = 0; leftspeed = 0; jump = 0; } onClipEvent(enterFrame){ if(Key.isDown(Key.RIGHT)){ rightspeed = rightspeed + 10; } rightspeed = rightspeed - 2.5; this._x = rightspeed; } onClipEvent(enterFrame){ if(Key.isDown(Key.LEFT)){ leftspeed = leftspeed + 10; } leftspeed = leftspeed - 2.5; this._x -= leftspeed; } }else if(Key.isDown(Key.UP)){ this._y -= 3.5; }
-
Answer:
What does it do? The only thing I would add is this._x = ((rightspeed - 2.5)>0)?rightspeed - 2.5:0; and this._x = ((leftspeed - 2.5)>0)?leftspeed - 2.5:0; This is a short circuit evaluation if/else: if the math is > 0, apply it, otherwise set it to zero. Otherwise it will begin applying negative numbers to the position, taking it off the state - maybe that's what's wrong. Use trace('message') to debug, see documentation. trace('rightspeed is ' + rightspeed);
Lennon C at Yahoo! Answers Visit the source
Related Q & A:
- I need help on what I need to buy or do.Best solution by Yahoo! Answers
- I need help with some horse questions, can you help me.Best solution by Yahoo! Answers
- I did something really bad and now i need help please help me.Best solution by Yahoo! Answers
- Where can I find good a tutorial for creating a simple flash movie using Adobe Flash CS4?Best solution by Graphic Design
- What sort of opportunities are there to help people in Africa or places where people need help?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.