ippa / jaws

Jaws - HTML5 canvas javascript 2D Game Framework
https://jawsjs.ippa.se
GNU Lesser General Public License v3.0
363 stars 75 forks source link

CocoonJS integration #60

Closed DangerPenguin closed 11 years ago

DangerPenguin commented 11 years ago

Everything I'm doing works great in all the desktop browsers I've tested. But when i load up a Test Jaws game with a test game state inside of the CocoonJS launcher (for mobile devices) , I get the error below

JSUtilities Exception: TypeError: Result of expression 'asset' [undefined] is not an object. Line: 778 File: 1494923456 Tag: load

This happens whenever i try to make a new jaws.Sprite

I know it's because of the CocoonJS launcher, because it isn't a complete browser. It has a lot stripped out of it. But i was wondering if there was a way to get Jaws completely compatible with CocoonJS? Or if anyone has ran into this problem too?

ippa commented 11 years ago

can you set up an online example I can test? Use either jaws.js or jaws-dynamic.js so it's easy to track exactly what code errors.

McFunkypants commented 11 years ago

One thing worth mentioning is that cocoonJS doesn't allow cache busting image urls. So it won't load MYFILE.PNG?12345 But will load MYFILE.PNG

DangerPenguin commented 11 years ago

Sorry, was out of town and forgot the laptop. I've uploaded a sample game to my dropbox here https://dl.dropbox.com/u/38470106/CocoonJS%2BJaws%20error%20sample.zip

All im doing is making a test game state, where within it i declare a sprite and try to draw it. Works on browsers (sometimes have to refresh) but throws the same error i mentioned in my original post when loaded with CocoonJS on my Android galaxy nexus and iphone 4.

You will also see that i commented out a jaws asset load, as i thought that was throwing the errors at first (it might still be)

@McFunkypants honestly, i hadn't heard of cache busting so im pretty sure im not using it >_>but now to wikipedia that...

McFunkypants commented 11 years ago

@DangerPenguin there's a setting in jaws that adds a random number to the image download urls to prevent browser cache. Worth checking out, but this may be just a shot in the dark. I've also failed to get my game (which runs perfectly in browsers INCLUDING mobile browsers) to work in cocoonJS.

Another idea could be LARGE spritesheets and images. In a browser you can use huge images but in cocoonJS they recommend never going above 2048x2048, since these are turned into GPU textures.

DangerPenguin commented 11 years ago

Coming from a Android background, I still limit my sprite sheets to no bigger than 1024x1024 and always do a power of 2 for size (width and height).

I haven't gone too in-dept of digging through Jaws and havent seen that setting, what was it called?

ippa commented 11 years ago

jaws.assets.bust_cache = false ... I'll have to document that better :).

I'ts false by default though.

ippa commented 11 years ago

Revisiting this I see that I had docs for bust_cache-flag here: http://jawsjs.com/docs/symbols/jaws.Assets.html ... I made it slightly better just now.

Maybe it isn't easy to find, jsdoc which I use has certain limitations.. but it's there :). Since there's been no news in this ticket for 3 months I'm closing it.