valueerror Posted January 10, 2015 Share Posted January 10, 2015 nothing to add to this title..im working with p2 without collisiongroups for the moment... only onbegincontact events Link to comment Share on other sites More sharing options...
valueerror Posted January 11, 2015 Author Share Posted January 11, 2015 oke.. obviously there is more information needed... i'm trying to create a very simple game with some kids and i'm really confused the current problem is that setting sprite.body.collideWorldBounds = true; for any object disables ALL collisions for this object.. i just don't see why.. (i've never used this setting before so i have no experience on how to use it properly.. maybe i made a simple coding error.. thx for your help! here's the code: (the flower doesn't collide with the other objects because of the worldbounds setting)function create() { game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 1000; cursors = game.input.keyboard.createCursorKeys(); game.add.tileSprite(0,0,800, 600, 'clouds'); ball1 = game.add.sprite(200,140,'ball'); game.physics.p2.enable( ball1 ); ball1.body.setCircle(32); ball1.body.damping = 0.9; flower1 = game.add.sprite(402,50,'flower'); game.physics.p2.enable( flower1 ); flower1.body.setCircle(32); flower1.body.damping = 0.9; flower1.body.collideWorldBounds = false; schmetti = game.add.sprite(400,200,'schmetti'); game.physics.p2.enable(schmetti); schmetti.body.setCircle(25); bowlingballs = game.add.group(); bowlingballs.add(ball1); bowlingballs.add(flower1);}function update() { if (cursors.right.isDown){schmetti.body.moveRight(300);} if (cursors.left.isDown) {schmetti.body.moveLeft(300); } if (cursors.up.isDown) {schmetti.body.moveUp(300); } bowlingballs.forEach(position);}var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {preload:preload, create:create, update:update});function position(mitglied){ if (mitglied.body.y >= 550){ mitglied.body.y = 40; }} Link to comment Share on other sites More sharing options...
yousifucv Posted January 29, 2015 Share Posted January 29, 2015 The property name "collideWorldBounds" is misleading.What happens is that when you create physics bodies in P2 they all get assigned and put into a default collision group, that includes the world boundaries.When you set "collideWorldBounds" to false you remove it from that group and so it collides with nothing else that is also in the default group. You will have to set up collision groups to get the desired effect you want. Link to comment Share on other sites More sharing options...
valueerror Posted January 30, 2015 Author Share Posted January 30, 2015 well.. it works with collision groups... for my beginner students i was hoping to get around them for now... thx! Link to comment Share on other sites More sharing options...
Recommended Posts