Search the Community
Showing results for tags 'physics.arcade'.
-
Example: https://jsbin.com/cakorijiqi/1/edit?js,output Physics.ARCADE collision trouble. Sprite fall through the another sprite if hight velocity. If you change the value from 500 to 100 in the velocity, then the problem does not occur. this.boxGroup.setAll('body.velocity.y', 500); What is the cause of the problem? And I have noticed. If the swap these lines (#2, #3), the box to fall through the floor. function update() {//#1 game.physics.arcade.collide(this.boxGroup); //#2 game.physics.arcade.collide(this.floor, this.boxGroup);//#3 }//#4 Sorry for my English. Thanks.
- 3 replies
-
- physics.arcade
- collision
-
(and 1 more)
Tagged with:
-
I have some little squares with text being drawn with bitmapData to a sprite (very scrabble like). I am calling them tiles but they are not Phaser tiles. When dragging them, I want them to bump into each other instead of the dragged square going on top of the other squares. Here is a demo of my problem: http://phaser.io/sandbox/edit/HXZjATTw I am generating 3 draggable tiles in my example (they are stacked ontop of eachother). When you drag them around they only collide with the little Phaser man and not the platforms or the other tiles. Any thoughts on why my tiles wont bump into eachother? In the create() I am running this: var player;var platforms;var cursors;var jumpButton;var canvasZoom = 32;var tileHandGroup;var spriteWidth = 15;var spriteHeight = 15;var tiles = ["h", "j", "k"];function create() { function tiley(i){ game.physics.startSystem(Phaser.Physics.ARCADE); var bmd = game.add.bitmapData(canvasZoom, canvasZoom); // draw to the canvas context bmd.ctx.beginPath(); bmd.ctx.rect(0, 0, canvasZoom, canvasZoom); bmd.ctx.fillStyle = '#efefef'; bmd.ctx.fill(); bmd.ctx.fillStyle = '#234234'; bmd.ctx.font="20px Georgia"; bmd.ctx.fillText(tiles[i], 7,23); var tileSprite = game.make.sprite(32, 32, bmd); game.physics.arcade.enable(tileSprite); tileHandGroup.add(tileSprite); console.log(tileHandGroup); tileSprite.inputEnabled = true; tileSprite.input.enableDrag(true); } tileHandGroup = game.add.physicsGroup(Phaser.Physics.ARCADE); game.physics.enable(tileHandGroup, Phaser.Physics.ARCADE); for (var i = 0; i < tiles.length; i++) { tiley(i); } tileHandGroup.setAll('body.immovable', true); tileHandGroup.setAll('body.moves', false); tileHandGroup.setAll('body.collideWorldBounds', true); /// player = game.add.sprite(100, 200, 'player'); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; player.body.gravity.y = 500; platforms = game.add.physicsGroup(); platforms.create(500, 150, 'platform'); platforms.create(-200, 300, 'platform'); platforms.create(400, 450, 'platform'); platforms.setAll('body.immovable', true); cursors = game.input.keyboard.createCursorKeys(); jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);}function update () { game.physics.arcade.collide(tileHandGroup, tileHandGroup); game.physics.arcade.collide(player, platforms); game.physics.arcade.collide(player, tileHandGroup); game.physics.arcade.collide(platforms, tileHandGroup); player.body.velocity.x = 0; if (cursors.left.isDown) { player.body.velocity.x = -250; } else if (cursors.right.isDown) { player.body.velocity.x = 250; } if (jumpButton.isDown && (player.body.onFloor() || player.body.touching.down)) { player.body.velocity.y = -400; }}