Jump to content

Equivalent of FlxSprite.stamp()


Recommended Posts

There are 2 approaches you could take (both of these are for Phaser 1.0 which I'll release tomorrow)


1) Use a DynamicTexture. This is like a hidden canvas that you can draw to, it can also be set as the texture for a Sprite. So you could have the head and eyes drawn to the DynamicTexture and then use it as the texture for your player sprite in game.


2) However for the example you gave I think it would be more efficient to just use a Group that had 2 sprites inside of it, one for the head and the other for the eyes. You would have to keep track of the coordinates of each part, but it would save rendering them to another canvas. You can set each one to use a sprite sheet (or a texture atlas) and just change the frame as needed.

Link to comment
Share on other sites

DynamicTexture is what I was looking for. Looking at DynamicTexture.pasteImage(), it doesn't seem to support pasting a single frame from an animation yet (the code is commented out). I hope it will be implemented at the release.


I am trying DynamicTexture right now, and I will let you know if it did work well.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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