This is, probably, a really newbie question, I don’t know if it is the right place to ask, but, well, is it possible to rotate a movieclip and reset its rotation point while maintaining the rotated state?
For example, if I do this on a mC:
testObject.rotation = 90;
Can I keep the object rotated and just reset its rotation to 0?
The way I would approach it is using another variable to save the last “pinned” rotation, and a setter for “new rotation” that will take into account the pinned rotation when calculating.
mc.rotation = 90;
var pinned = mc.rotation;
var newRotation (get, set):Float
function set_newRotation(value)
{
mc.rotation = pinned + value;
}
But I wonder if there is a “trick” in the haxe language itself to achieve this, because I’m also new to the language…
The thing to do is to always have the parent/child arrangement.
class CustomRotationObject extends Sprite {
private var child:DisplayObject;
public function new(child:DisplayObject) {
super();
addChild(child);
}
public function setDefaultRotation():Void {
child.rotation += rotation;
rotation = 0;
}
}
Usage:
var rotatedTestObject = new CustomRotationObject(testObject);
addChild(rotatedTestObject);
rotatedTestObject.rotation = 90;
rotatedTestObject.setDefaultRotation();
This will cause the child to appear at 90° when the parent is at 0°.
Sorry for diverting the subject a little bit, but I’m now exploring the language, and I was wondering if this could help (instead of overriding), or maybe I misunderstand it?
That would allow you to add the setDefaultRotation method yes,
but it wouldn’t allow to customize the constructor.
(which btw isn’t missing a this.child = child?)
Guess I’ll have to stick with the parent-child relationship and re-think the way I’m building things here, or maybe simplify my idea, since it looks like it isn’t possible to rotate + override the rotation property…