HTML5 oddity warning
Monkey Targets Forums/HTML5/HTML5 oddity warning
| ||
I'm guessing the majority will never experience this, but... I've been banging my head for weeks over a bit of code I made in an older Monkey revision that I loaded up in the new revision and it didn't work. Still worked in Flash, didn't work in HTML5. Well, I'm (mostly) sure I've found the culprit, finally. Apparently an OnRender call is no longer generated by Monkey in HTML5 without an OnUpdate call. So if all you want to do is put an image on the screen, you still need to make your program pretend it's doing something continuously or, as Wilder's Wonka would say, "YOU GET NOTHING!" |
| ||
Every time you change to a different build, you're supposed to delete the game's previous .build folder. The App class already has OnUpdate being called with or without you overwriting it in the extended App class. |
| ||
I had in fact deleted the .build folder. I had even copied the code to a new project. Nothing worked (in HTML5) until I added a SetUpdateRate() |
| ||
...or you could just try this vs uncommented and see for yourselfImport mojo Function Main() New MyApp End Class MyApp Extends App ' Method OnCreate() ' SetUpdateRate(60) ' End Method OnRender() Cls(0,0,0) End End |
| ||
Oh, you said OnUpdate. Yeah, it won't run without OnCreate and SetUpdateRate. Without an update rate, how is it supposed to know how many updates to do a second. And since OnRender tries to get called at the same frequency as OnUpdate, without that rate, it'll never be called. |
| ||
I would expect an app without an update rate to draw at least once. For example, static image generators for page backgrounds. [edit] actually you can change OnRender to OnLoading to get a single render out of an HTML5 app with above example but not so for flash |
| ||
Exactly. And it used to - and it still does in anything I've tested *except* HTML5. |
| ||
Agreed. |
| ||
This isn't new behaviour: http://monkeycoder.co.nz/Community/posts.php?topic=754#6009 And yes, it's inconsistent and I consider it a bug. |
| ||
Ah. Well, it's been several revisions since I last used Monkey and I found nothing on the topic via search. At least Mark is presumably aware. |