fuzzee Posted February 18, 2014 Share Posted February 18, 2014 Physics is new to me for game dev. I want the sprite to increase and decrease in size and have the bounding physics shape stay the same size as the sprite. I add the body to the world ok, but then can't change the size of the shape later...Actor = game.Class.extend({ init: function() { this.sprite = new game.Sprite(200, 200, 'media/logo.png', { anchor: {x: 0.5, y: 0.5} }); this.body = new game.Body({ position: {x: this.sprite.position.x, y: this.sprite.position.y}, CollisionGroup: 1, mass: 0 }); var shape = new game.Rectangle(this.sprite.width, this.sprite.height); this.body.addShape(shape); game.scene.world.addBody(this.body); game.scene.stage.addChild(this.sprite); game.scene.addObject(this); }, update: function() { this.sprite.height = 10; this.body.shape.height = 10; }}); Now I want to do this in the udpate:this.body.shape.height = 10;//ORgame.scene.world.bodies[0].shape.height = 10;But, that doesn't work. I could try with each update to remove the body from the world and then add the body back with the new size, but that doesn't seem right. Any ideas? Thanks. Quote Link to comment Share on other sites More sharing options...
enpu Posted February 18, 2014 Share Posted February 18, 2014 Hi,Thanks for the post. It seems that the physics shape height is actually changing, but the debug draw shape is not. I just pushed new version of debug.js into develop branch, that should be fixed:https://github.com/ekelokorpi/panda.js/blob/develop/src/engine/debug.js Let me know if that works! Quote Link to comment Share on other sites More sharing options...
fuzzee Posted February 18, 2014 Author Share Posted February 18, 2014 All sorted. Working as expected. I was only looking at the debug draw shape and didn't think it was working. Thanks for the quick response. Quote Link to comment Share on other sites More sharing options...
enpu Posted February 18, 2014 Share Posted February 18, 2014 Great! Let me know, if you have any other problems 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.