Running multiple Monkey apps on a single page

Monkey Targets Forums/HTML5/Running multiple Monkey apps on a single page

DruggedBunny(Posted 2013) [#1]
I found that you can't easily embed multiple Monkey apps due to conflicts/overrides between separate main.js files.

However, if you simply embed each app in its own iframe, there's no conflict.

Here's a quick demo showing two separate Monkey apps (with two instances of each app):

http://www.hi-toro.com/monkey/multicanvas/demo.html

... and a sample layout with instructions for rolling your own:

http://www.hi-toro.com/monkey/multicanvas.zip

Just in case anyone else finds they need to do this!


TFT(Posted 2013) [#2]
Hi,

it is fantasic ..... for my multiplayer card game test system.

thx


Amon(Posted 2013) [#3]
Cool!


rIKmAN(Posted 2013) [#4]
haha, nice work!


ElectricBoogaloo(Posted 2013) [#5]
For your processor's sake, I won't be adding this feature to AGameAWeek! ;)

Neat find.


DruggedBunny(Posted 2013) [#6]
Just had a quick scan of your blog -- no idea how you do a game a week. Each of those would take me a year and never get finished!

But has that ios audio problem you mentioned here been reported as a bug? I don't see it in versions.txt and I'm sure it's something Mark would fix ('specially with code provided!), as he had a similar problem on XNA/Xbox that got sorted.

With regards to the multiple apps, you could probably disable/enable them on losing/gaining focus, or enter a 'pause' mode, though AGAW would still probably be slight overkill!

@TFT: I'd be interested to know if that works, hadn't thought of that!


ElectricBoogaloo(Posted 2013) [#7]
... did I have an audio issue? Hmm.. Sorry, tend to forget things after about a week! My mind's gotten used to blanking out previous weeks, and just moving on, instead!

You probably mean the "Background Stops" thing. I got that sorted, and added it to my big Monkey->iOS Checklist thing.
To be fair, it's not actually a bug, but it'd be nice to have it as an option, rather than "Forced Stop, or Tweak it Yourself"..
Still, an easy thing to tweak, once you've figured out how the smeg to do it!

-=-=-

Yeah, having multiple mini multiplayer things running all at once would be great for testing. It's also nice to know that you can easily do tiny-embed code, with a simple iframe. I might rejig a bunch of my framework to allow for that sort of thing. Would be nice to have. .. I think..


Paul - Taiphoz(Posted 2013) [#8]
Yeah I used and use iframes as well, but some browsers still have issues with how they get displayed which might cause you problems.


ElectricBoogaloo(Posted 2013) [#9]
To be fair, that's pretty much the case doing anything, if you dare to target HTML5!
No matter how well you code, IE's bound to break something along the way.


Paul - Taiphoz(Posted 2013) [#10]
Bloody MS , you goto love and hate them, I really dont know why they dont just get their shit in order, there is a clear standard and their still trying to fight it with their own crap.

pisses me off that I need to have a css file just for IE, which still happens a lot when coding something for the web.


David Casual Box(Posted 2013) [#11]
Thanks for the tip. We're already using iFrame, not to run multiple instance, but to deal with the cache issues when we need to update our game...


David Casual Box(Posted 2013) [#12]
ElectricBoogaloo, what Framework are you using to deal with screen size, etc. in your (amazing) games a week?


ElectricBoogaloo(Posted 2013) [#13]
I HAS MAIKED MAI OWN!

Monkey Skeleton January - February - March - June

.. With the forewarning that, since I'm working at a fairly fast pace, I tend to just throw stuff together. It's not really meant for public consumption!


Salmakis(Posted 2013) [#14]
hey, how you managed this not to stop when its not on focus?

whatever i try here, when i click somewhere else my stuff is on pause and i wont get any onUpdate or onRender calls anymore.


David Casual Box(Posted 2013) [#15]
Salmakis, it's a mystery for me too. I got some game made with Monkey that are not stoping when I click outside, and now all my new projects stop when they lost focus.
I guess it's a change in Monkey?


rIKmAN(Posted 2013) [#16]
Have you guys tried using #MOJO_AUTO_SUSPEND_ENABLED = True/False to enable/disable pausing when clicking outside the game canvas?

Works for me.