So, is the scale update generally working ok on FlxSpriteGroup, with some limitations that I overlooked, or is it that the scale update isn't complete yet ?
Thanx!
So is this the supposed behavior or not ? How can I achieve what I want to do ?
I'm posting the code for the test Scene
var cnt:FlxSpriteGroup;
var parent:FlxNestedSprite;
var scale1Txt:FlxText;
var scale2Txt:FlxText;
override public function create():Void{
super.create();
cnt = new FlxSpriteGroup();
add(cnt);
var spr1 : FlxSprite = new FlxSprite(80, 80);
spr1.makeGraphic(40, 40, FlxColor.RED);
var spr2 : FlxSprite = new FlxSprite(80, 80);
spr2.makeGraphic(20, 20, FlxColor.BLUE);
cnt.add(spr1);
cnt.add(spr2);
parent = new FlxNestedSprite(160, 80);
parent.makeGraphic(40, 40, FlxColor.YELLOW);
add(parent);
var child1 : FlxNestedSprite = new FlxNestedSprite(0, 0);
child1.makeGraphic(20, 20, FlxColor.GREEN);
var child2 : FlxNestedSprite = new FlxNestedSprite(0, 0);
child2.makeGraphic(20, 20, FlxColor.GRAY);
child2.relativeX = 20;
child2.relativeY = 20;
parent.add(child1);
parent.add(child2);
var groupTestBtn:FlxButton = new FlxButton(60, 20, "Test Group", testGroupScale);
var nestTestBtn:FlxButton = new FlxButton(140, 20, "Test Nested", testNestedScale);
add(groupTestBtn);
add(nestTestBtn);
scale1Txt = new FlxText(60, 0, 80, "scale=");
add(scale1Txt);
scale2Txt = new FlxText(140, 0, 80, "scale=");
add(scale2Txt);
}
public function testGroupScale():Void {
//scale up and tween back to original scale
cnt.scale.set(3, 3);
var cntScaleTween : FlxTween = FlxTween.tween(cnt.scale, { x: 1, y: 1 }, 3.0, { ease:FlxEase.elasticOut, startDelay:1.5 } );
}
public function testNestedScale():Void {
//scale up and tween back to original scale
parent.scale.set(3, 3);
var parentScaleTween : FlxTween = FlxTween.tween(parent.scale, { x: 1, y: 1 }, 3.0, { ease:FlxEase.elasticOut, startDelay:1.5 } );
}
override public function update():Void
{
super.update();
scale1Txt.text = "scale=" + cnt.scale.x;
scale2Txt.text = "scale=" + parent.scale.x;
}
Please guys, help me out here..
P.s: I tried with Flixel 3.3.6 also!
postUpdate
methodpublic function postUpdate():Void {
// ....Skipping some code here
for (child in children)
{
if (child.active && child.exists)
{
child.velocity.x = child.velocity.y = 0;
child.acceleration.x = child.acceleration.y = 0;
child.angularVelocity = child.angularAcceleration = 0;
child.postUpdate();
if (isSimpleRender())
{
child.x = x + child.relativeX - offset.x;
child.y = y + child.relativeY - offset.y;
}
else
{
var radians:Float = angle * FlxAngle.TO_RAD;
var cos:Float = Math.cos(radians);
var sin:Float = Math.sin(radians);
var dx:Float = child.relativeX - offset.x;
var dy:Float = child.relativeY - offset.y;
// I think this probably won't do the job
var relX:Float = (dx * cos * scale.x - dy * sin * scale.y);
var relY:Float = (dx * sin * scale.x + dy * cos * scale.y);
child.x = x + relX;
child.y = y + relY;
}
child.angle = angle + child.relativeAngle;
child.scale.x = scale.x * child.relativeScale.x;
child.scale.y = scale.y * child.relativeScale.y;
child.velocity.x = velocity.x;
child.velocity.y = velocity.y;
child.acceleration.x = acceleration.x;
child.acceleration.y = acceleration.y;
}
}
}
...