Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong bounds in scaled objects #16

Open
eXponenta opened this issue Sep 2, 2020 · 0 comments
Open

Wrong bounds in scaled objects #16

eXponenta opened this issue Sep 2, 2020 · 0 comments

Comments

@eXponenta
Copy link
Member

eXponenta commented Sep 2, 2020

Related AwayFL.

getBounds return twice scaled bounds rectangle when Sprite is scaled.

AS3 test code:

import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.MovieClip;
import flash.geom.Point;

var node: Sprite = new Sprite();
var dot: Sprite = new Sprite();
var bounds: Sprite = new Sprite();

bounds.graphics.lineStyle(2, 0x0000ff);

addChild(node);
addChild(dot);
addChild(bounds);

dot.x = 100;
dot.y = 0;

dot.graphics.beginFill(0x0);
dot.graphics.drawCircle(0,0, 10);

node.scaleX = 0.5;
node.scaleY = 0.5;

node.graphics.beginFill(0x00ff00);
node.graphics.drawCircle(0,0, 100);

node.x = 275;
node.y = 200;


const t: Timer = new Timer(500);

var p0;
var p1;

t.addEventListener(TimerEvent.TIMER, function(e: *) {
	node.rotation += 45;
	
	var pos = node.localToGlobal(new Point(100,0));
	
	dot.x = pos.x;
	dot.y = pos.y;
	
	var r = node.getBounds(null);
	p0 = new Point(r.x,r.y);
	p1 = new Point(r.x + r.width, r.y + r.height);
	
	p0 = node.localToGlobal(p0);
	p1 = node.localToGlobal(p1);
	
	bounds.graphics.clear();
	bounds.graphics.lineStyle(2, 0x0000ff);
	
	bounds.graphics.drawRect(p0.x, p0.y, p1.x - p0.x, p1.y - p0.y);
})

t.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant