Nikow Posted March 5, 2015 Share Posted March 5, 2015 Hi ! I'm trying to make a game with collisions between two sprites, the hero and the earth ( a sphere).. When i'm writting this : bgFront = this.game.add.sprite(game.width/2,game.height*1.8,"planeteFront");bgFront.anchor.setTo(0.5,0.5);game.physics.enable(bgFront, Phaser.Physics.ARCADE);bgFront.body.immovable = true; My sprite bgFront ( which is my sphere) is falling down... I don't understand why ? Thank you ! Edit 1 : i've add bgFront.body.moves = false; my sprite doesn't move now, but the hero passes through ...? Link to comment Share on other sites More sharing options...
stauzs Posted March 5, 2015 Share Posted March 5, 2015 you need to add collision check: function collisionHandler(obj1, obj2){ //do something on collision}update: function(){ //your update code here game.physics.arcade.collide(bgFront, SPHERE, collisionHandler, null, this);}check this example": http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=sprite+vs+sprite.js&t=sprite%20vs%20sprite Link to comment Share on other sites More sharing options...
rich Posted March 6, 2015 Share Posted March 6, 2015 My sprite bgFront ( which is my sphere) is falling down... I don't understand why ? Gravity? Immovable means another object can't influence it, i.e. another sprite colliding with it. But it will still react to world physics, local forces, etc - unless told not to. Also Arcade Physics has no concepts of spheres (or circles) at all - bear this in mind before you get much further You may need to swap to P2. Link to comment Share on other sites More sharing options...
Nikow Posted March 6, 2015 Author Share Posted March 6, 2015 Gravity? Immovable means another object can't influence it, i.e. another sprite colliding with it. But it will still react to world physics, local forces, etc - unless told not to. Also Arcade Physics has no concepts of spheres (or circles) at all - bear this in mind before you get much further You may need to swap to P2. Thank you ! P2 physics looks like awesome ! Link to comment Share on other sites More sharing options...
Recommended Posts