I am working on a game in which the player must fight enemies and go through obstacles in an eagle's eye perspective. I need to make it so when the player attacks an enemy, it gets knocked backwards so it won't die right away. This is the code:onClipEvent(load){ knock = false; knockback = 30;}onClipEvent(enterFrame){if(knock == true){ knockback -= 5; if(_root.Player._rotation >= 45 && _root.Player._rotation <= 135){ this._x += knockback; } if(_root.Player._rotation >= 135 && _root.Player._rotation <= 225){ this._y += knockback; } if(_root.Player._rotation >= 225 && _root.Player._rotation <= 315){ this._x -= knockback; } if(_root.Player._rotation >= 315 && _root.Player._rotation <= 405){ this._y -= knockback; } if(knockback < 1){ knockback = 30; knock = false; }}}Everything works except the bold statements. The enemy cannot fly left or upwards.Could anyone tell me why that is? Thanks in advance.
I'm pretty sure that the rotation only goes to 180. Try replacing it with negatives instead (360- whatever you need, but then add negative).
I don't understand what you are saying. You want to change it to this?if(_root.Player._rotation >= -225 && _root.Player._rotation <= -315){ this._x -= knockback;}or like this?if(_root.Player._rotation >= -45 && _root.Player._rotation <= -135){ this._x -= knockback;}
yeah thats what he means... Flash uses 180 degree lines... so anything above the line would be like +65 anything below would be -65
Ok thanks! It worked! The battling system works really well and looks amazing.
Great! Hope the game does well.
You must be logged in to post a reply!