bbyford Posted June 7, 2021 Share Posted June 7, 2021 I'm using getBounds for hit detection and getBounds doesnt seem to return the bounds with rotation on the object. The sprite is being created and added to the scene and thats it before i query it's bounds. I've tried with and without .calculateBounds() before .getBounds() var card = new Sprite(Resources.cardBack.texture); card.x = (30 - getRandomInt(120)) + (col * 150) + width / 4; card.y = (30 - getRandomInt(60)) + (row * 100) + 30; card.interactive = true; card.cursor = 'pointer'; card.name = "card"+i; card.scale.x = _card_scale; card.scale.y = _card_scale; card.hitArea = new PIXI.Rectangle(11, 11, 130, 180); card.rotation = degreesToRadians(getRandomInt(180)-90); card.calculateBounds(); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 7, 2021 Share Posted June 7, 2021 (edited) I think you have to assign something as parent, then transform wil be updated correctly. addChild it to temporary root Edited June 7, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
bbyford Posted June 7, 2021 Author Share Posted June 7, 2021 sorry what do you mean here? I add it to a container and then the stage after this point as it wouldnt appear otherwise on screen, then do getBounds Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 7, 2021 Share Posted June 7, 2021 (edited) a hack. Because of pixi transforms strange behaviour. let tempContainer = new Container(); tempContainer.addChild(sprite); sprite.getBounds(); //sometimes later container.addChild(sprite); //automatically removed from temp one Edited June 7, 2021 by ivan.popelyshev bbyford 1 Quote Link to comment Share on other sites More sharing options...
bbyford Posted June 7, 2021 Author Share Posted June 7, 2021 13 minutes ago, ivan.popelyshev said: a hack. Because of pixi transforms strange behaviour. let tempContainer = new Container(); tempContainer.addChild(sprite); sprite.getBounds(); //sometimes later container.addChild(sprite); //automatically removed from temp one will give it ago, thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.