Jump to content

show frame of frame of atlas


Recommended Posts

Sorry if the title isn't clear but can't seem to figure out how to write it.

Let me explain:

I have a group object which should contain 3 sprites (idle, highlight, reveal) can be considered as a button.

  • The object is idle when nothing happens (idle sprite/image)
  • The object goes into highlight mode (highlight sprite/image on top of idle sprite/image) when hovering
  • The objects texture gets replaced by the reveal sprite/image when the object has been clicked.

As for the sprites, I bundled each group of 3 images (idle, highlight, reveal) into 1 big image.

To put this in code:

var HiddenPlace = function(game, parent, options) {
  Phaser.Group.call(this, game, parent);

  this.revealed = false;

  // Create Base Spritesheet-object from atlas so a simple framenumber can be used
  var sprite = this.load('sprites', 'sym' + options.item+ '.png');
  this.idleObj = this.create(options.x, options.y, sprite, 0);
  this.highlightObj = this.create(options.x, options.y, sprite, 1);
  this.highlightObj.alpha = 0;

  this.onReveal = new Phaser.Signal();
  this.onHighlight = new Phaser.Signal();
  this.removeHighlight = new Phaser.Signal();

I know this code wouldn't work but I hope you understand what I'm trying to achieve.


Is that possible?


Link to comment
Share on other sites


  • Recently Browsing   0 members

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