collinhover/impactplusplus

Scaling all images

Closed this issue · 10 comments

I thought I would be able to figure this out, but I've not solved it yet. I'm working on getting the game to work better on slow systems by using smaller images, lower frame rates, etc.

So, I'm trying to load the game with 50% sized images and scale them x2, but I can't figure out how to do this. The only thing I've been able to do is scale the entire entity or game screen. Is there a way to do this?

@itsOgden hmm, can you provide a sample code snippet of how you're going about this? You should be able to set image scale independently. Have you looked at https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/core/image.js#L66 ?

That said, I don't think you're going to see any performance improvement here, as the canvas will have to draw the same number of pixels whether the image is 100% or 50% scaled x2. I could be wrong :-)

@itsOgden I think @collinhover is right on the performance topic. On top of that, scaling has an impact on the performance too as far as I know. So making your images smaller, and scaling them up to the intended size, would worsen your performance, in comparison to just use them in the original size.

Or is this more about loading time related to the game assets, and not about the actual performance of the game?

Good use of the performance property of my entities gave me some performance boosts. Also make sure to prerender your backgrounds. Play around with that a little. Make sure what is responsible for performance problems on slower machines. If you might have an idea what's going on, we could try to help you optimize your game.

Sorry, I wasn't clear enough about this. The purpose is to allow it to load on devices such as iPads. Our game currently runs super smooth on computers, but it crashes when trying to load the assets on any mobile platform. The idea was to see if .5 sized images would load up and see how that turned out.

@collinhover, https://github.com/collinhover/impactplusplus/blob/master/lib/plusplus/core/image.js#L66 looks like it would work, but I can't seem to get it to work, but maybe I'm using it incorrectly. How would you apply that to loading/using an image?

My first guess is it is crashing because your images are exceeding the max texture size for mobile, usually around 2048x2048? I think even if you scale the original image down, in order to scale it up for drawing it will again exceed the max size. Is this the case? If so, can you break your images up?

All of our images are 2048x2048 or lower. I was assuming it was the sheer file sizes that were crashing it, but I just checked and actually it's only 3MB total. That's very perplexing.

I also just checked the performance when scaling (though it wasn't scaled properly because entity sizes were all jacked up) and it murdered the frame rate... So that's not going to be an option, just like you suggested.

I have no idea now what's causing the crash though, but I don't think it's the file size nor would scaling help. Sorry to jump the gun, guys!

If your game gets scaled up at all and you have an image or canvas at 2048, you will crash because you've exceeded the max texture size. Does your game dynamically resize/scale?

How are you running the game on the iPad? Ejecta or using Safari? Which iPad model? I've had great success running my game on a non-Retina iPad with textures up to 4096x4096 using Ejecta. Errors, when they did occur, were output to XCode's debug window.

On Jun 19, 2014, at 12:58 AM, itsOgden notifications@github.com wrote:

All of our images are 2048x2048 or lower. I was assuming it was the sheer file sizes that were crashing it, but I just checked and actually it's only 3MB total. That's very perplexing.

I also just checked the performance when scaling (though it wasn't scaled properly because entity sizes were all jacked up) and it murdered the frame rate... So that's not going to be an option, just like you suggested.

I have no idea now what's causing the crash though, but I don't think it's the file size nor would scaling help. Sorry to jump the gun, guys!


Reply to this email directly or view it on GitHub.

@collinhover The canvas resizes with the window (up to full size only), but the game itself does not dynamically scale, no.

@aroth Well, at the moment, Safari. At one point we had the game worked on Safari relatively well so I was hoping to be able to maintain that throughout development. It's seems as though that may not be a possibility. Unfortunately I don't know how to get Safari to log errors either.

@itsOgden You may want to try to wrap your game in an app using Ejecta. There are quite a number of enhancements over Safari that you may find useful, as well as improved error reporting.

@itsOgden One last thing -- I just tried my game and it does not work well at all in Safari on an iPhone 5. Textures are missing, sound doesn't play, and inputs aren't responsive. I think a couple of these issues are what inspired the creation of Ejecta. If you have the ability, you may want to check it out. Cheers.

http://impactjs.com/ejecta