Search the Community
Showing results for tags 'sprite size'.
-
Hi all. I try to get width/height properties in pixels with object PIXI.extras.AnimatedSprite but all time it return 1. How i can do that? In the object this properties is true console.log
-
If I do this: function paddleUpdate() { if(isPaddleNerfed) { paddle.frameName = "paddle_small.png"; //48px width } else { paddle.frameName = "paddle_big.png"; //32px width } //Do I have to set the size manually like this paddle.body.setSize(paddle._cache.width, paddle._cache.height); } I ask because with: game.debug.renderSpriteBounds(paddle); I see the pink border and it's changing size (but only visually): collisions and also sprite.body.width still returns the old bigger size rather than the smaller/nerfed one... Also visually it's all ok... and also sprite._cache.width returns correct values. Is my aproach right or is there a better, shorter way ... i clearly understand that it can't and shouldn't be automatic because changing sprite/frames should change the collision body region... but maybe it can be added as option ... or maybe shouldn't I'll be glad to here more opinions about this. EDIT: I just saw that there is: game.debug.renderSpriteBody(paddle); so the only question that leave is this the proper way of doing it since the sprite.body isn't updating on sprite size/frame change
- 4 replies
-
- sprite size
- frame
-
(and 2 more)
Tagged with:
-
Well the topic title says all I was lazy enought to want to not use: sprite.width / 2; //works as expected so i tried: sprite.halfWidth; //undefined so checked the phaser source and saw i have to use: sprite._cache.halfWidth //works as expected ... but doen't feel ok _cache... Also there is this: sprite.body.halfWidth //works as excepted but i'm not 100% sure that this isn't the physics body width and not the sprite width So a little info to clear this topic will be cool ?
- 1 reply
-
- halfWidth
- halfHeight
-
(and 1 more)
Tagged with: