Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Hazneliel

Hello, any idea why Im having 25fps on Mozilla Firefox and like 3fps on Iphone Safari??

My game is barely starting and Im not doing heavy calculations, its just a pong game based on the tutorial.
Here you can see it:
http://www.znelarts.com/minimalBreaker/

I really need support for this because the engine doesnt seem to be the quality I was told before I purchase it.

Thank you

1 decade ago by Hazneliel

I just realized even the Demo Pong has really low FPS, so this is the performance of the engine, it really lacking of optimization then

Demo with fps display:
http://www.znelarts.com/gamez/pong/index.html

1 decade ago by MikeL

Not exactly sure why yours seems to be different, but please have a look at this post to make sure the engine stays as private as possible. Reminder Bake It Don't Break It

I'm sure there's a reason to be found.

1 decade ago by MikeL

Actually I get 30-40 FPS with your pong link on my Firefox Browser. I have found the best frame rates with Chrome. Again be sure to refer to this post ASAP before you post any more games or tests: Reminder Bake It Don't Break It.

1 decade ago by Hazneliel

I have everything right except for the obfuscations since Im still developing. But Im getting slow fps even when I load your demo pong from my iphone. I think I need to call serious support because of this issue.

1 decade ago by MikeL

Read the post again carefully and follow the directions for which files and folders to include. Again it is very important to keep the entire game system as private as possible. Hang in there.

1 decade ago by dominic

Hey Hazneliel, in regards to the performance issues on mobile devices: the Impact on mobile platforms article explains some stuff.

The main problem is that you're not drawing the game in the native resolution of the device. Likewise, the Pong demo isn't optimized for mobile as well.

The physics demo or the Biolab Disaster game work well on iOS.

1 decade ago by Hazneliel

I baked my game http://www.znelarts.com/minimalBreaker/ using MikeLĀ“s instructions, It still runs at low fps and I even reduced the screen size to get just close to 40fps in a core 2 computer. Why the game doesnt run at 60fps as it is told in the main.js script???

Hey Dominic, The native resolution of an iphone 4 would be 640x960, and I will be using tiles of 4x4, How would that run? if I just said I had to reduce the screen size to 80x120 which is eight times the native resolution and it still doesnt run at an aceptable fps

For the task I have assigned I really need something that manages efficiently and can run at good fps on modern browsers

1 decade ago by dominic

Baking doesn't make your game run faster, it just makes the source code harder to read.

Well that's not entirely true, Google's Closure Compiler has some optimizations that make the script a little faster. But I would be surprised if the performance increase would even be measurable in a typical game.

I have no idea why the game runs slow for you; It runs with constant 60fps in Chrome on Firefox4 for me. This may be a problem with your graphics driver, as some older drivers/graphics cards are blacklisted and don't use hardware acceleration in the browser.


Here's the thing: whether you run your game with 640x960 and a scaling of 1, or 80x120 and a scaling of 8 - the speed on the iPhone4 will be about the same, because both are rendered by Impact with 640x960 in the end. This is done, because scaling a canvas after every frame (via CSS) is extremely slow. This also means that a 'viewport scale' of the page that is not 1 is really slow. So make sure, as the article suggests, to add the following to your html page:

<meta name="viewport" content="width=device-width; 
	initial-scale=1; maximum-scale=1; user-scalable=0;"/>

Now, because of the iPhone's 'devicePixelRatio' of 2, a "pixel" on an HTML page essentially corresponds to 2 pixels (well, 2x2) on the screen you have to ensure that a game that you set to run in 640x960 will be rendered in a manner where one virtual HTML pixel corresponds to one pixel on the screen. You also have to force the #canvas element to be 'scaled down' to these virtual pixels:

#canvas {
	width: 320px;
	height: 480px;
...
}

(I'm sorry, this is pretty hard to explain, but I think the article I mentioned before does a decent job at it :))

One more thing: every call to draw an image takes some time - especially on mobile devices. Therefore you typically want to reduce the number of draw calls as much as possible. Because background maps are made up of hundreds of tiles, drawing them can be quite slow, if you draw them tile by tile. However, Impact has a mode for pre-rendered backgrounds that will speed up things immensely on mobile devices. With pre-rendered backgrounds, the tilesize of your background maps doesn't matter much anymore.

Again, there's some more detail about all this in the Impact on mobile platforms article.


I modified your version of the game a bit; I hope you don't mind - it now runs with 60fps on my iPhone3GS (may be a bit slower on the iPhone4 - see the article for the reason :)): Try this:
http://impactjs.com/files/temp/breaker/

Note that the size of the game screen is still a bit too large to show up nicely in the iPhone's browser. The screen height of the iPhone minus the browser's navigation bar on the bottom and the status bar on the top is 420px (or 840 'real' pixels on the iPhone4), not 480px.


Things I changed in your code:

The CSS definition of the #canvas element and the viewport meta-tag in the .html file.

The call to ig.main() - This will render the game in 320x480 on the iPhone3 and 640x960 on the iPhone4:
ig.main('#canvas', MinimalBreaker, 60, 160, 240, 2 * ig.ua.pixelRatio);

And I also added this method to your game class, to enable the pre-rendered background mode on all background layers:
loadLevel: function(data) {
	this.parent(data);
	for( var i = 0; i < this.backgroundMaps.length; i++ ) {
		this.backgroundMaps[i].preRender = true;
	}
},

I hope that clarifies a few things.

1 decade ago by Hazneliel

Well, that clarifies a lot of things and I really apreciate your excelent support. Thank you, I will be experimenting with your advices.

1 decade ago by Hazneliel

Glad to let you know that your optimization advices made my app run at 60fps on Mozilla, still a problem in the iphone 4 but it seems thats a problem with the IOS.

Thanks again for your excelent support.

1 decade ago by dominic

Glad that I could help :)

I still don't have an iPhone4 to test this on and I don't think it will run with 60fps there, but it should run with a decent, playable frame rate. I.e. at least 20fps. It's always a bit of a hassle to get the screen size right everywhere.
Page 1 of 1
« first « previous next › last »