lars Posted December 11, 2015 Share Posted December 11, 2015 Hey Having trouble removing my body from an eventgame.createClass('ChristmasPackage', { init: function(myimg,myscale) { var myPumkingsVelocityArray = [100, 80, 60, 50, 40, 32, 45, 67, 78, 98, 90]; var pumkingVInterval = myPumkingsVelocityArray[Math.floor(Math.random() * myPumkingsVelocityArray.length)]; var x = Math.random(16, game.system.width); this.pumkins = new game.Sprite(myimg); this.pumkins.interactive=true; this.pumkins.anchor.set(0.5, 0.5); this.pumkins.scale.set(myscale, myscale); this.body = new game.Body({ position: { x: x, y: -this.pumkins.height }, velocity: { x: 0, y: pumkingVInterval }, collisionGroup: 1, collideAgainst: [0], mass: 0, }); this.body.collide = this.collide.bind(this, myimg); var shape = new game.Rectangle(90, 90); this.body.addShape(shape); game.scene.stage.addChild(this.pumkins); game.scene.world.addBody(this.body); game.scene.addObject(this); This is the function where i try to remove the body this.pumkins.click = this.pumkins.tap = function(e) { game.scene.world.removeBody(); //this.body.remove(); };//function end }Can anyone help me here ... :-) Quote Link to comment Share on other sites More sharing options...
Stephan Posted December 13, 2015 Share Posted December 13, 2015 Try this:game.scene.world.removeBody(this.body) 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.