HTML5 oddity warning

Monkey Targets Forums/HTML5/HTML5 oddity warning

xAD(Posted 2011) [#1]
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!"


Goodlookinguy(Posted 2011) [#2]
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.


xAD(Posted 2011) [#3]
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()


xAD(Posted 2011) [#4]
...or you could just try this vs uncommented and see for yourself

Import mojo

Function Main()
	New MyApp
End

Class MyApp Extends App

'	Method OnCreate()
'		SetUpdateRate(60)
'	End

	Method OnRender()
		Cls(0,0,0)
	End

End



Goodlookinguy(Posted 2011) [#5]
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.


skid(Posted 2011) [#6]
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


xAD(Posted 2011) [#7]
Exactly. And it used to - and it still does in anything I've tested *except* HTML5.


skid(Posted 2011) [#8]
Agreed.


muddy_shoes(Posted 2011) [#9]
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.


xAD(Posted 2011) [#10]
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.