jimanji Posted November 11, 2016 Share Posted November 11, 2016 Hello, I am running into an issue where I have an empty sprite and add lots of children items to it. When I debug this item, my frame box to show my sprite is very tiny. If I use body.setSize I can make the empty sprite get bigger, but I haven't been able to figure out how to do this programmatically because whenever I try to use width it gives me the scale size .3. If the empty sprite has no size the depth sorting does not work so it makes my sprite always behind everything, like the ground. If I try to use other functions like LocalBounds I get the x, y, .3, .3. I want to get the actual pixel size of what the sprite and its children make up even if the parent sprite is an empty sprite. Is this possible? I am also using the isometric plugin if that helps. Here is probably the most relevant code to get the idea. this.model is an isometric sprite. (<any>this.game.physics).isoArcade.enable(this.model); this.model.body.collideWorldBounds = true; this.model.body.x = this.game.world.width * 0.5; this.model.body.y = this.game.world.height * 0.5; this.model.anchor.set(0.5); this.model.scale.set(0.3, 0.3); this.model.body.setSize(150, 150, 300, 0); //i want to set the size to be the entire size of the empty sprite + it's children this.model.width is scale size .3, but it looks like setSize requires pixels? this.game.debug.body(this.model, 'rgba(189, 221, 235, 0.6)', false); Link to comment Share on other sites More sharing options...
squilibob Posted November 12, 2016 Share Posted November 12, 2016 what does this.model.body.getBounds().width & this.model.body.getBounds().height return for you? Link to comment Share on other sites More sharing options...
jimanji Posted November 12, 2016 Author Share Posted November 12, 2016 it does not look like the body has that functionality with this plugin. i still have not found a solution. I would think it would be kind of easy to get this info, like the width and height on the sprite is the scale size and not the pixel size. Link to comment Share on other sites More sharing options...
squilibob Posted November 12, 2016 Share Posted November 12, 2016 you say this.model.width is scale size .3 but are you supposed to use this.model.widthX and this.model.widthY ? Link to comment Share on other sites More sharing options...
jimanji Posted November 12, 2016 Author Share Posted November 12, 2016 i think i at least understand the problem more now. the empty sprite must have a default of 1x1 so its not the scale size i am seeing, it really is .3 pixels wide. i was doing some testing with left and right and came to this conclusion. if this is the case then my children in the sprite are not considered when calculating the size. Link to comment Share on other sites More sharing options...
jimanji Posted November 14, 2016 Author Share Posted November 14, 2016 Sprite.getbounds and displayobjectcontainer.getbounds have different functionality. the displayobjectcontainer does calculate the children but a sprite does not. I had to write some custom stuff to calculate this and then set the size of the sprite. so I did figure out a solution for this. Link to comment Share on other sites More sharing options...
Recommended Posts