sashastg Posted January 12, 2017 Share Posted January 12, 2017 Hello, first of all, thanks for PIXI JS. i want to know if i am doing everything correctly (bcz i am still not satisfacted with performance on mobile), and i am looking any performance optimization which i can do. i use latest pixi js (4.3.0). before i used 3.x.x and there was no any positive difference with my game. (maybe after i updated pixijs i lost some performance, but its just on eye). my game using autoDetectRenderer. and often its WEBGL, but anyways i see fps down. ok, i just want to know if i am doing everything correctly. i have a lot of animations, thats why i am using spritesheets. 1) i am preloading all spritesheets/fonts/images/etc, using Loader. loader.add("redAnim", "sheets/redAnim.json"); etc... 1.1) i am using spritesheet for interfaces and different buttons such as play button, music button, bars etc... is there any boost performance to use spritesheets instead of a lot of small images? 2) MY MAIN QUESTION: for add animation to stage i am using next: var frames = getFramesUtil(39, "red_stay/0000"); this.image = new PIXI.extras.MovieClip(frames); function getFramesUtil(count, pattern){ var frames = []; for (var i=0; i<=count;i++){ var str = "" + i; var pad = pattern; var ans = pad.substring(0, pad.length - str.length) + str frames.push(PIXI.Texture.fromImage(ans)); }; return frames; }; So, i am using Pixi.Texture.fromImage or also i am using PIXI.Sprite.fromImage so as i understand they must get items from Loader right? i just want to be sure that i am doing everything correctly. best regards, Alexander Quote Link to comment Share on other sites More sharing options...
merachefet Posted January 14, 2017 Share Posted January 14, 2017 It's probably reloading them each time, the fromImage methods aren't intended for that. Access your loaded frames like this: sprite.texture = loader.resources["animation.json"].textures["walkcycle1"] Using spritesheets is more efficient because if you draw ten things in a row from the same spritesheet, the texture is only being loaded to the GPU once. It's slower to load a lot of small textures one at a time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.