haden Posted August 11, 2013 Share Posted August 11, 2013 Is there in phaser an equivalent of FlxSprite.stamp(sprite:FlxSprite) ?I have a sprite that contains various heads, each in a frame, and another sprite with various eyes...and I want to draw custom sprites in my game using a specific head and eye,... Link to comment Share on other sites More sharing options...
powerfear Posted August 11, 2013 Share Posted August 11, 2013 I believe you should be able to replicate that by drawing what you want on an offscreen canvas and then making an image from that canvas. Link to comment Share on other sites More sharing options...
rich Posted August 11, 2013 Share Posted August 11, 2013 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 More sharing options...
haden Posted August 12, 2013 Author Share Posted August 12, 2013 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. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts