Uhfgood Posted September 14, 2014 Share Posted September 14, 2014 I want to cut down on the amount of graphics I'm making so I would like to make the large versions of my asteroids, and then scale them down. But I want to scale them down once at the beginning so I'm not doing it in real-time. Is there a way to pre-scale sprites within phaser? Link to comment Share on other sites More sharing options...
nuvorm Posted September 14, 2014 Share Posted September 14, 2014 Use an object pool maybe?Basically create all objects at runtime and then recycle them,I wrote an generic object pooler that does exactly that.I can send you the class if you are interested. I dont think scaling has a huge impact on performance though. Link to comment Share on other sites More sharing options...
Uhfgood Posted September 14, 2014 Author Share Posted September 14, 2014 What does an object pool have to do with pre-scaling your sprites? I want to cut down on the size of my graphics on disc that less image data, meaning, when I make my sprites in a paint program or spriting program, I make less. Link to comment Share on other sites More sharing options...
Noid Posted September 14, 2014 Share Posted September 14, 2014 If you're worried about the disk space the game occupies, using the engine to scale the graphics won't help because the original assets will still be the big ones and they'll be there occupying space even if the game is not running. Why don't you scale them down when you export them from your graphics program to .png? Keep the editable version full size, but scale the graphics that go into the final game. Link to comment Share on other sites More sharing options...
Uhfgood Posted September 15, 2014 Author Share Posted September 15, 2014 I have 3 sizes of asteroids -- it doesn't matter much to me if the original assets are the bigger ones... the smaller ones will just be taking up space. In any case, no problems, if you can't do it, you can't do it. Link to comment Share on other sites More sharing options...
Noid Posted September 15, 2014 Share Posted September 15, 2014 I see...There's Phaser.BitmapData that you can use to create the scaled textures. Phaser.BitmapData.copy() has a scaleY and scaleX argument and there is also Phaser.BitmapData.resize().I've never used any of those but maybe that's what you're looking for. Link to comment Share on other sites More sharing options...
nuvorm Posted September 15, 2014 Share Posted September 15, 2014 >But I want to scale them down once at the beginning so I'm not doing it in real-time.>Is there a way to pre-scale sprites within phaser?>What does an object pool have to do with pre-scaling your sprites? in an object pool you can prescale the sprite and (re)use it in your game maybe? If an object is taken from the pool the sprite is already scaled, therefor you might call it pre scaled. also as i already said, "I dont think scaling has a huge impact on performance though." so you might want to just load the bitmap and scale it to your needs in the sprite with sprite.scale.setTo(n,n). Link to comment Share on other sites More sharing options...
Uhfgood Posted September 16, 2014 Author Share Posted September 16, 2014 I think it's just what I want, now if I can only figure out how to use it :-) thanks! I see...There's Phaser.BitmapData that you can use to create the scaled textures. Phaser.BitmapData.copy() has a scaleY and scaleX argument and there is also Phaser.BitmapData.resize().I've never used any of those but maybe that's what you're looking for. Link to comment Share on other sites More sharing options...
Recommended Posts