Gameventions Posted January 16, 2015 Share Posted January 16, 2015 Hi I am new to phaser, having trouble manipulating objects that are in a group: this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.physics.arcade.gravity.y = 60; this.allAsteroids = this.game.add.group(); this.asteroid = this.allAsteroids.create(DoomSpinner.convertWidth(400), DoomSpinner.convertHeight(50),'white1'); this.game.physics.arcade.enableBody(this.asteroid); val = Math.random()*30-15; this.asteroid.velocity.x=val; this.asteroid.body.angularAcceleration = val;I get a cannot set property 'x' of undefined error. I plan on having lots of asteroids, so how can I give them velocity and still use them in a group? Thanks for answering the noob question. Link to comment Share on other sites More sharing options...
rich Posted January 16, 2015 Share Posted January 16, 2015 I can see 2 typos:this.game.physics.arcade.enable(this.asteroid);andthis.asteroid.body.velocity.x = val; Link to comment Share on other sites More sharing options...
Gameventions Posted January 16, 2015 Author Share Posted January 16, 2015 Thanks! Whats the difference between enable and enableBody? Link to comment Share on other sites More sharing options...
rich Posted January 16, 2015 Share Posted January 16, 2015 enable is the function you should use. You can pass it a sprite, or a whole array of them and it'll work happily. enableBody is the internal function that enable relies on. Link to comment Share on other sites More sharing options...
Recommended Posts