Jump to content

Problem With Terrain Destruction


Ezowolf
 Share

Recommended Posts

Hey all, still pretty new to Phaser. I'm trying to create destructable terrain akin to games like Worms.

The problem I have now is that it seems the visual part of the land only seems to update on the first frame. 

However, the console logs stop, indicating that there's no longer an image, even though there's still visibly an image.

This is the code I have now:

Quote

var land;
var Game =
{
  init: function()
  {
      game.renderer.renderSession.roundPixels = true;
  },

  preload:function()
  {
    Game.load.image('land','Assets/Images/land.png')
  },

  create:function()
  {
    game.stage.backgroundColor = "#4488AA";
    land = Game.add.bitmapData(992, 480);
    land.draw('land');
    land.update();
    land.addToWorld();
  },

  update:function()
  {
    if((land.getPixel(game.input.mousePointer.x,game.input.mousePointer.y).a)>0)
    {
      console.log("Terrain Found");
      DestroyTerrain();

    }
  }
}

function DestroyTerrain()
{
  land.blendDestinationOut();
  land.circle(game.input.mousePointer.x,game.input.mousePointer.y, 16, 'rgba(1, 0, 0, 255)');
  land.blendReset();
  land.update();
}

 

Anybody with more experience with Phaser know what might cause this?

 

8d6e3fb88a337ccbc92377aa4e6e78b5.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...