Sprite.rotation does not work if it is not initialized with a value different than 0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
jeash |
Fix Committed
|
Undecided
|
Niel Drummond |
Bug Description
create a test using this code:
package ;
import flash.display.
import flash.display.
import flash.events.Event;
import flash.events.
import flash.geom.Point;
import flash.geom.
import flash.display.
class SpaceShip extends Sprite
{
var _bmp:Bitmap;
var _mouseDown:Bool;
public function new()
{
super ();
var bitmapData = nme.Assets.
_bmp = new Bitmap(bitmapData);
this.
this.
this.
_mouseDown = false;
}
private function onMouseDown(
{
_mouseDown = true;
}
private function onStage(
{
stage.
this.
var rect:Rectangle = _bmp.getBounds(
_bmp.x -= ((rect.width / 2));
_bmp.y -= ((rect.height / 2));
x = (stage.stageWidth / 2);
y = (stage.stageHeight / 2);
}
private function onRender(
{
this.rotation = CalcRotation();
}
private function CalcRotation(
{
if (_mouseDown == false) return this.rotation;
return 57;
}
}
Once the mouse is clicked, instead to see a sudden change of rotation like expected, the sprite will be also translated to the corner of the screen (right down in my case);
IF the sprite rotation is initialize to 1 inside the OnStage function, then everything works as expected.
Because it's not a pure haxe/jeash project and uses NME, I cannot compile this as it is posted.
Is it possible that you zip your project, with Assets, with NMML file, and Source directories so I can compile it without deviating from the code you have provided ?