Search the Community
Showing results for tags 'destructible'.
-
Hello, I'm trying to implement the code from this tutorial in a game I'm making. Actually I can make the holes on the texture using bitmapData. This is how I'm doing: this.bmd = game.make.bitmapData(360, 150); this.bmd.copy('ground'); //ground = image key //Makes two "holes" this.bmd.blendDestinationOut(); this.bmd.circle(50, 10, 20, 'rgba(0, 0, 0, 255'); this.bmd.circle(70, 10, 20, 'rgba(0, 0, 0, 255'); this.bmd.blendReset(); this.bmd.update(); this.ground = this.add.sprite(0, 630, this.bmd); this.game.physics.arcade.enable(this.ground); this.ground.body.allowGravity = false; this.ground.body.immovable = true; However, when I move my player, it walks like if there's no hole on the ground: How can I fix this?
- 14 replies
-
- destructible
- terrain
-
(and 1 more)
Tagged with:
-
Hey, I want to create a scratch card effect, as there are in games with luck and all where you scratch on some image and in the scratched area you can see the image below it. I think this can be done by manipulating pixels somehow, but i am not experienced with pixi and don,t know how to do it exactly. It will be a great help if you point out a way or tutorial to do it, or give a basic code snippet here to help me figure this mechanism out. Regards.
- 4 replies
-
- scratch
- destructible
-
(and 2 more)
Tagged with:
-
Hi all, I've managed to do a very simple but not very flexible code to damage and destruct tiles when shooting at them. I have a Json map, one layer with an image for not destructible tiles and a second layer with a sprite-sheet with 4 frames for the 4 damage levels (see image). My problem is that one bullet collision result in one step in the damage progression. What I want is to have different damage thresholds for different weapons: a pistol has to shoot 10 bullets to move to the next damage level, a machine gun needs only 5, and a bomb destroys the tile immediately. Thank you for any help I'm pasting here only the relevant code, I've omitted stuff like moving the player or particle effects: (edited code formatting) create: function() { this.createWorld(); //OTHER CODE OMITTED... },update: function() {} update: function() { game.physics.arcade.collide(this.player, this.layerWorld); game.physics.arcade.collide(this.player, this.layerDirt); game.physics.arcade.overlap(this.bulletPool, this.layerDirt, this.destroyTerrain, null, this); this.shootBullet(); //OTHER CODE OMITTED... },//OTHER CODE OMITTED... createWorld: function(){ //create the tilemap this.map = game.add.tilemap('level1'); //add tileset images to the map this.map.addTilesetImage('worldBase'); this.map.addTilesetImage('worldDirt'); //crete layers from every json layer this.layerWorld = this.map.createLayer('worldBase'); this.layerDirt = this.map.createLayer('worldDirt'); //enable collisions for the first frame this.map.setCollision(1, true, this.layerWorld); //enable collision for all frames in sprite this.map.setCollision([26,27,28,29], true, this.layerDirt); //set the world size to match the size of the layer this.layerWorld.resizeWorld(); //set bounds to world game.world.setBounds(0,0,3200, 320); },//OTHER CODE OMITTED... destroyTerrain: function(bullet, tile) { //move the emitter at the bullet's point of contact with the tile this.dirtParticles.x = bullet.x; this.dirtParticles.y = bullet.y; //start emitting //start(explode, lifespan, frequency, quantity) this.dirtParticles.start(true, 2000, null, 15); //advance to the next tile's id tile.index += this.BULLET_DAMAGE; if(tile.index < 29) { this.map.putTile(tile.index, tile.x, tile.y, this.layerDirt); } else if (tile.index >= 29) { this.map.removeTile(tile.x, tile.y, this.layerDirt); } bullet.kill();},