Using java Syntax Highlighting
- public void setLocalVelocity(float X, float Y){
- final float playy=((float) Math.cos(MathUtils.degToRad(this.getRotation()))*Y)+(float) Math.sin(MathUtils.degToRad(this.getRotation()))*X;
- final float playx=((float) Math.sin(MathUtils.degToRad(this.getRotation()))*-Y)+((float) Math.cos(MathUtils.degToRad(this.getRotation()))*X);
- this.setVelocity(playx, playy);
- }
- public void setLocalAcceleration(float X, float Y){
- final float playy=((float) Math.cos(MathUtils.degToRad(this.getRotation()))*Y)+(float) Math.sin(MathUtils.degToRad(this.getRotation()))*X;
- final float playx=((float) Math.sin(MathUtils.degToRad(this.getRotation()))*-Y)+((float) Math.cos(MathUtils.degToRad(this.getRotation()))*X);
- this.setAcceleration(playx, playy);
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
So using setLocalVelocity(0,10) would always move the sprite in the positive Y direction with respect to it (which in most cases would be down
and setting setLocalVelocity(10,0) would always move the sprite in the positive X direction with respect to itself (should be to the right)
