Kinerius Posted October 9, 2015 Share Posted October 9, 2015 Hi let me explain what im trying to do here: I need to merge 2 big sprite sheets into one using Render texture with .renderXY() method.It works OK, but now the problem is i don't have animation frames created for it ( thing that game.loader.spritesheet does )so im trying to do something like this:this.game.cache.addRenderTexture(key,renderTexture);sprite.animations.frameData = Phaser.AnimationParser.spriteSheet(this.game,key,width,height);but then i realized phaser does this in the AnimationParser.spriteSheet method: if (typeof key === 'string') { img = game.cache.getImage(key); } if (img === null) { return null; }Is there a workaround for this? Link to comment Share on other sites More sharing options...
Tom Atom Posted October 10, 2015 Share Posted October 10, 2015 Hi, here is solution, how to create frame data to render texture // create render texture var width = 300; var height = 300; this._prerendered = new Phaser.RenderTexture(aGame, width, height); // add render texture to cache with "MyRenderTexture" key (currently its frameData property is not defined) this.game.cache.addRenderTexture("MyRenderTexture", this._prerendered); // create frame data var frameData = new Phaser.FrameData(); // add single frame "frame0" to it frameData.addFrame(new Phaser.Frame(0, 50, 50, 100, 100, "frame0")); // assign created frameData to our render texture this.game.cache.updateFrameData("MyRenderTexture", frameData, Phaser.Cache.RENDER_TEXTURE); // just to test ... read "frame0" back from cache var frame = this.game.cache.getFrameByName("MyRenderTexture", "frame0", Phaser.Cache.RENDER_TEXTURE); jmp909 1 Link to comment Share on other sites More sharing options...
Kinerius Posted November 24, 2015 Author Share Posted November 24, 2015 Sorry for the late response, that worked! Thanks! Link to comment Share on other sites More sharing options...
pyre Posted March 17, 2017 Share Posted March 17, 2017 I could create the render texture and get the frames back, but I couldn't create a sprite sheet from it. Whenever I tried to create a sprite with that texture, I couldn't set the frame on it without effecting all sprites sharing that texture. Instead, I created a spritesheet from a bitmap data object: game.cache.addSpriteSheet('key',null,bitmapdata.canvas, framewidth, frameheight); Link to comment Share on other sites More sharing options...
Recommended Posts