tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/3327-go-modular-for-multiple-gamesRobotlegs: Discussion 2013-07-02T07:35:50Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T08:47:42Z2013-06-20T08:47:42ZGo modular for multiple games?<div><p>hi,</p>
<p>I would appreciate some advice about how to set up my project.
Let me describe what I want.</p>
<p>It is an AIR desktop app that shows two games, first game A,
then game B, then game A again - but with other content - et
cetera.<br>
Game B needs to know a little about Game A, for instance the
'content theme' or the speed.<br>
Both games need to listen to the same sort of data, for instance
keyboard input.<br>
Both games share the same views, but only partly, for instance the
game over view.<br>
Both games could share the same commands but only partly. For
instance, when the keyboard is pressed<br>
a service should send certain data to an external device, but the
data are different.</p>
<p>I want to use RL2 because it has a ViewManager which makes it
easier for me to work with multiple windows/monitors.</p>
<p>One thing that comes to mind is working with 'modules' which
also seems to be possible with RL2, using the ModuleExtension,<br>
but the threads I read about it and the examples I saw look kinda
daunting so far.<br>
I also feel I should use a common library that is shared by the two
games. And if needed, extended, because another thing that comes to
mind is working with inheritance, extending commands and views.<br>
Another thought is create the games in separate RL2 projects -
using code from a common lib, compile them as SWFs and load them
into a main AIR app.</p>
<p>So I wonder how I can 'add' two games, with their own contexts
to a main 'shell' and allow each game to listen to events (signals)
dispatched by the main app. Is this possible without going
modular?<br>
And do the games need their own contexts? If not, would that not
end in a lot of 'if game A ...else if game B...' statements,
something I don't prefer?</p>
<p>Sorry if I'm a bit vague and my questions - and the title of
this post - may not be very specific, but I hope you can share some
thoughts,</p>
<p>thanks,<br>
Jeff.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T08:56:02Z2013-06-20T08:56:02ZGo modular for multiple games?<div><p>Hey Jeff;</p>
<p>Just a quick answer, before digesting your entire post;)</p>
<p>Take a look at the Module Connector, which ist he new way of
communicating between multiple contexts.<br>
<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/modularity">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a></p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T09:15:13Z2013-06-20T09:15:13ZGo modular for multiple games?<div><p>Next iteration:</p>
<p>Loading the games as Modules or as separate applications is
quite similar.</p>
<blockquote>
<p>I also feel I should use a common library that is shared by the
two games.</p>
</blockquote>
<p>That’s right, the shared classes should reside inside a
library.</p>
<p>Take a look at my answer here:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/3285-help-with-splitting-big-app-into-core-and-extensions#comment_27394609">
http://knowledge.robotlegs.org/discussions/robotlegs-2/3285-help-wi...</a></p>
<p>to see how you can make use of different configuration
classes.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T09:20:37Z2013-06-20T09:20:37ZGo modular for multiple games?<div><blockquote>
<p>And do the games need their own contexts?</p>
</blockquote>
<p>Yep, I’d definitely let each game have its own
context!</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T09:44:22Z2013-06-20T09:44:22ZGo modular for multiple games?<div><p>Thanks, Ondina.<br>
What I just don't see yet is - when you work with modules - how you
'load' and 'start' and also 'reset' or 'unload' a module. Usually,
when I have one project with one context there is smt like a
startup command. I guess that if I add the two contexts and a shell
to one project, I should move startup code to the shell, dispatch
an event from the shell and if a module listens for it, then that
module does its thing?</p>
<p>When I want to switch to the other module, how would I
stop/cleanup/reset/unload/whatever the first module?</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T09:59:33Z2013-06-20T09:59:33ZGo modular for multiple games?<div><blockquote>
<p>What I just don't see yet is - when you work with modules - how
you 'load' and 'start' and also 'reset' or 'unload' a module.</p>
</blockquote>
<p>In Flex I use a ModuleLoader. Should I paste a code snippet? Or,
are you rather asking which shell class should load/unload the
module? Please clarify this.</p>
<blockquote>
<p>When I want to switch to the other module, how would I
stop/cleanup/reset/unload/whatever the first module</p>
</blockquote>
<p>OK, I’ll try to explain this. Just need a little bit more
time.<br>
I actually have an example where I’m trying different things
out, like the new rl2 ModuleConnector. I can’t show you the
entire code yet, because it’s still a mess :) But I’ll
paste some relevant code (note: it’s Flex though)</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T10:17:48Z2013-06-20T10:19:03ZGo modular for multiple games?<div><p><em>In Flex I use a ModuleLoader</em><br>
Are you referring to Flex modules or to RL modules now? I'm working
in a pure as3 project as you remember correctly ( I ported the
already existing game A from rl1 to rl2 the other day, quite easy
to do btw).</p>
<p>I was asking about how the (one and only) shell loads a RL
module. Can I use RL modules in an as3 project? Then I would love
to see a very basic example albeit in flex :)</p>
<p>I still wonder if I need modules at all, why not just each game
its own context. If I do that could I still have communication
between my main app and the two game contexts, without modules?</p>
<p>Btw, how do you do that <em>quote</em> format in a post? Don't
see it in the formatting help...</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T10:42:10Z2013-06-20T10:42:10ZGo modular for multiple games?<div><p>There are no “rl modules”. When you (everyone) say
“rl modules”, you actually mean multiple contexts. You
could (but you shouldn’t) let each and every component in
your app have its own context. All you need to do is to let rl know
what to use as a contextView.</p>
<p>So, if you add GameA to the stage, you instantiate the context
with GameA (or a sub-component) as the contextView.</p>
<blockquote>
<p>I still wonder if I need modules at all, why not just each game
its own context. If I do that could I still have communication
between my main app and the two game contexts, without modules?</p>
</blockquote>
<p>I’m currently writing down an explanation for you about
how to configure the 3 contexts and how to communicate between
them. I’ll be back… sooner or later;)</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T11:26:32Z2013-06-20T11:45:50ZGo modular for multiple games?<div><p>GamesCenter is the main application, and it will load GameA and
GameB alternatively.<br>
We are talking about 3 contexts: ShellContext, GameAContext, and
GameBContext.</p>
<p>In order to work with multiple contexts, we need the
ModularityExtension, which is part of the MVCSBundle. With the
ModularityExtension installed we’ll have access to the
IModuleConnector.</p>
<p>Now, let’s configure the 3 contexts.</p>
<p>ShellContext</p>
<pre>
<code>public function ShellContext(view:DisplayObjectContainer)
{
context = new Context()
.install(MVCSBundle)
.configure(ControllersConfig)
.configure(ModelsConfig)
.configure(ServicesConfig)
.configure(MediatorsConfig)
.configure(ShellConnectorConfig);
.configure(new ContextView(view));
}</code>
</pre>
<p>GameAContext</p>
<pre>
<code>public function GameAContext(view:DisplayObjectContainer)
{
context = new Context()
.install(MVCSBundle)
.configure(ControllersConfig)
.configure(ModelsConfig)
.configure(ServicesConfig)
.configure(MediatorsConfig)
.configure(GameAConnectorConfig);
.configure(new ContextView(view));
}</code>
</pre>
<p>GameBContext</p>
<pre>
<code>public function GameBContext(view:DisplayObjectContainer)
{
context = new Context()
.install(MVCSBundle)
.configure(ControllersConfig)
.configure(ModelsConfig)
.configure(ServicesConfig)
.configure(MediatorsConfig)
.configure(GameBConnectorConfig);
.configure(new ContextView(view));
}</code>
</pre>
<pre>
<code>public class ShellConnectorConfig implements IConfig
{
[Inject]
public var moduleConnector: IModuleConnector;
public function configure():void
{
moduleConnector.onDefaultChannel()
.relayEvent(ModularConnectorEvent.SHELL_TO_MODULES);
moduleConnector.onChannel('A-and-B')
.receiveEvent(ModularConnectorEvent.A_TO_B_MESSAGE);
moduleConnector.onChannel('A-and-B')
.receiveEvent(ModularConnectorEvent.B_TO_A_MESSAGE);
}
}</code>
</pre>
<pre>
<code>public class GameAConnectorConfig implements IConfig
{
[Inject]
public var moduleConnector: IModuleConnector;
public function configure():void
{
moduleConnector.onDefaultChannel()
.receiveEvent(ModularConnectorEvent.SHELL_TO_MODULES);
moduleConnector.onChannel('A-and-B')
.relayEvent(ModularConnectorEvent.A_TO_B_MESSAGE);
moduleConnector.onChannel('A-and-B')
.receiveEvent(ModularConnectorEvent.B_TO_A_MESSAGE);
}
}</code>
</pre>
<pre>
<code>public class GameBConnectorConfig implements IConfig
{
[Inject]
public var moduleConnector: IModuleConnector;
public function configure():void
{
moduleConnector.onDefaultChannel()
.receiveEvent(ModularConnectorEvent.SHELL_TO_MODULES);
moduleConnector.onChannel('A-and-B')
.receiveEvent(ModularConnectorEvent.A_TO_B_MESSAGE);
moduleConnector.onChannel('A-and-B')
.relayEvent(ModularConnectorEvent.B_TO_A_MESSAGE);
}
}</code>
</pre>
<p>Now, the ShellContext can dispatch
ModularConnectorEvent.SHELL_TO_MODULES, and any class inside
GameAContext that registered a listener for it, can hear that
event. ShellContext listens to the events dispatched by GameA and
GameB on channel 'A-and-B'. GameA listens for
ModularConnectorEvent.B_TO_A_MESSAGE, and GameB to
ModularConnectorEvent.A_TO_B_MESSAGE. Yes, I know, it makes you
dizzy :)</p>
<p>Now let’s add the 2 “modules”. If you’re
not using Flex, you’ll probably add your GameA or GameB using
addChild(), right? Of, course you could load them as swfs, too.</p>
<p>Anyway, onAddedToStage you do this in GameA:</p>
<p>context = new GameAContext (this);</p>
<p>and, you guessed it, context = new GameBContext (this); in
GameB.</p>
<p>When you remove a game from the shell, its context will be
automatically destroyed, and re-created if you add it again to the
stage.</p>
<p>Try it out in a simple project, and let me know how it goes.<br>
I don’t think I’ll have the time today to make a pure
as3 example, but I’ll attach my Flex example as soon as I get
it cleaned up. If you want, you can attach your as3 app built as
shown above, and I’ll take a look at it.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T11:42:18Z2013-06-20T11:42:18ZGo modular for multiple games?<div><p>omg, thanks for this code, I could never have figured this out
:)<br>
I'll let you know how it goes!</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T14:14:57Z2013-06-20T14:14:57ZGo modular for multiple games?<div><p>Hehe, no problem.</p>
<p>I'm attaching the Flex (actually AIR) example I've talked about.
It's still work in progress, but perhaps you can understand better
what I meant in my previous messages after taking a look at the
classes. If you want, I can attach the released AIR app, too, to
see it in action.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T14:25:43Z2013-06-20T14:25:43ZGo modular for multiple games?<div><p>Very cool, Ondina. Maybe it's a good idea to make this an
official RL<br>
bare-bones example on modular communication?<br>
It's a question which comes back a lot.<br>
We already added you to the RL contributors team on Github. If you
push<br>
this to a GH repo I can fork it to the RL contributors team.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T14:31:47Z2013-06-20T14:31:47ZGo modular for multiple games?<div><p>Ooh, thanks, creynders !! :)</p>
<blockquote>
<p>Maybe it's a good idea to make this an official RL bare-bones
example on modular communication?</p>
</blockquote>
<p>But it’s kind of a doodle, really. I should at least add
comments and make it look nicer, no?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T14:47:31Z2013-06-20T14:47:31ZGo modular for multiple games?<div><p>Great, Ondina, I got your example running and will try to
convert it to an as3 project. Or create one of my own based on your
example.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:01:57Z2013-06-20T15:01:57ZGo modular for multiple games?<div><p>Please try to convert my example to an as3 project. If my
example is meant to become an official demo, as creyenders
suggested, it would be really cool to have it in 2 flavors: Flex
and pure as3 ;) I’ll have to refine my example a bit, so,
maybe you should wait a few days?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:30:41Z2013-06-20T15:30:41ZGo modular for multiple games?<div><p>Btw, what was a bit confusing in your project to me initially is
that I needed to compile the modules into SWFs - by making them my
default application, and that they ended up in my bin folder so
that I had to move them to the associative component folder or
simply change the path to the module SWFs.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:42:00Z2013-06-20T15:42:00ZGo modular for multiple games?<div><p>I don’t know what IDE you use, but in FlashBuilder all
you’d have to do would be to add the FlexModules to the
project. (Project->Properties->Flex Modules->add –
where you choose the views in question) In Flex they land in the
bin-debug folder, but the compiler knows about them…</p>
<blockquote>
<p>simply change the path to the module SWFs</p>
</blockquote>
<p>Yes, that’s all that’s required, actually.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:43:32Z2013-06-20T15:43:32ZGo modular for multiple games?<div><p>Oh, I wasn't familiar with that, never worked with FlexModules
:)</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:50:03Z2013-06-20T15:50:03ZGo modular for multiple games?<div><p>The Modules are: SomeModule, SomeOtherModule and AnotherModule.
I’ll have to change the comment in ShellContextView
accordingly and also to mention how to add them in FlashBuilder.
Maybe I'll come up with better names for the modules, as well.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:53:50Z2013-06-20T15:53:50ZGo modular for multiple games?<div><p>Yes, I compiled all three of them the unorthodox way and they
are being loaded. Will check out the FB feature of adding modules.
The names sound fine to me, I would just add some more
comments.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T15:56:49Z2013-06-20T15:56:49ZGo modular for multiple games?<div><p>Ok, Jeff.<br>
Any other questions will be answered tomorrow :)</p>
<p>Untill then, you can join our "party" at:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/problems/2516-let-the-robotlegs-2-party-begin-everyones-invited">
http://knowledge.robotlegs.org/discussions/problems/2516-let-the-ro...</a></p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-20T17:04:27Z2013-06-20T17:04:27ZGo modular for multiple games?<div><p>@ondina yeah, obviously there's some refactoring and commenting
to do, but I really like the idea of having a very clear, basic
example w/o any<br>
distracting extra stuff. I myself always struggle with filtering
out the<br>
cruft from the examples, when I'm learning something new. And it
shows<br>
people there's really no reason not to be using modules. They scare
people<br>
unnecessarily.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T09:53:23Z2013-06-21T09:53:23ZGo modular for multiple games?<div><p>@creynders</p>
<blockquote>
<p>I really like the idea of having a very clear, basic example w/o
any distracting extra stuff.</p>
</blockquote>
<p>Yes, good point. Less work for me as well.</p>
<p>There is a little problem with setting up the ModuleConnector,
and I want to discuss it with you.<br>
I understand that is difficult to find a way to prevent circular
relays, which happen if you have a setting like this:</p>
<pre>
<code>moduleConnector.onChannel('A-and-B')
.receiveEvent(ModularConnectorEvent.SOME_TYPE);
moduleConnector.onChannel('A-and-B')
.relayEvent (ModularConnectorEvent.SOME_TYPE);</code>
</pre>
<p>The question is: If I load several instances of a Module, how
can I communicate between them?<br>
I tried lots of things to make it work, even using guards, but
nothing helped, and even if it did, it would be a pretty convoluted
logic.<br>
I’m sure I’m missing something obvious. Help me see
it:)</p>
<p>With the ScopedEventDispatcherExtension it was possible to
communicate between instances of the same module. I’ll have
to make a lot of changes in my projects where I used the
ScopedEventDispatcherExtension.</p>
<p>Don’t get me wrong, relaying events is very cool!</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T10:37:34Z2013-06-21T10:37:34ZGo modular for multiple games?<div><blockquote>
<p>With the ScopedEventDispatcherExtension it was possible to
communicate between instances of the same module.</p>
</blockquote>
<p>How exactly did that work? The ModuleConnector basically works
the same way as the ScopedEventDispatcher behind the scenes. I
mean, the limitations of both should be the same.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T10:39:32Z2013-06-21T10:39:32ZGo modular for multiple games?<div><p>hi Ondina, creynders,</p>
<p>here is a pure as3 version of your demo, Ondina, I'm sorry I
couldn't wait for your cleaned up version.<br>
This one is an even more stripped down. It only has a shell and two
modules, no popups or extra windows. It seems to work well for me
but I hope you can take a look at the code to see if it looks
okay?</p>
<p>Jeff.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T10:43:39Z2013-06-21T10:43:39ZGo modular for multiple games?<div><p>Hi Jeff, I'll take a look at it!</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T11:26:21Z2013-06-21T11:26:21ZGo modular for multiple games?<div><blockquote>
<p>How exactly did that work?</p>
</blockquote>
<p>Easy:<br>
If you wanted a channel other than the default one, you did this in
the parent:</p>
<pre>
<code>context.extend(new ScopedEventDispatcherExtension("channelOne"));</code>
</pre>
<p>Then injected the dispatcher into the Modules, which inherited
from the parent:</p>
<pre>
<code>[Inject(name="channelOne")]
public var someSharedDispatcher:IEventDispatcher;</code>
</pre>
<p>then added listeners to and dispatched events on the
someSharedDispatcher.</p>
<p>I’m not saying that I like named injections, but it worked
well.</p>
<p>A pretty long explanation is here:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/68-modular-application">
http://knowledge.robotlegs.org/discussions/robotlegs-2/68-modular-a...</a></p>
<blockquote>
<p>I mean, the limitations of both should be the same.</p>
</blockquote>
<p>No, they are not the same, but it would take me too long to list
all the differences, or limitations…</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T11:37:15Z2013-06-21T11:37:15ZGo modular for multiple games?<div><p>@Jeff At first sight, it looks perfect :) I’ll go through
all the classes and let you know if there is anything that should
be changed. We can synchronize our projects after I’m done
with refactoring and commenting mine .</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T12:59:17Z2013-06-21T12:59:17ZGo modular for multiple games?<div><p>@ondina I don't get it. The ModuleConnector really just wraps an
API on top of the same mechanism as the
ScopeEventDispatcherExtension: it too uses a named mapping for an
event dispatcher. It literally does the same. That's why I don't
quite get how something you did with the SEDE wouldn't be possible
with the module connector.</p>
<p>This<br></p>
<pre>
<code>moduleConnector.onChannel('A-and-B').receiveEvent(ModularConnectorEvent.SOME_TYPE);
eventDispatcher.addEventListener(ModularConnectorEvent.SOME_TYPE);
moduleConnector.onChannel('A-and-B').relayEvent (ModularConnectorEvent.SOME_TYPE);
eventDispatcher.dispatchEvent(ModularConnectorEvent.SOME_TYPE);</code>
</pre>
<p>is the equivalent of<br></p>
<pre>
<code>[Injector(name='A-and-B')]
public var eventDispatcher:IEventDispatcher;
eventDispatcher.addEventListener(ModularConnectorEvent.SOME_TYPE);
eventDispatcher.dispatchEvent(ModularConnectorEvent.SOME_TYPE);</code>
</pre>
Surely that caused an infinite loop too?</div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T13:17:40Z2013-06-21T13:17:40ZGo modular for multiple games?<div><blockquote>
<p>Surely that caused an infinite loop too?</p>
</blockquote>
<p>I tried this already, and, yes, it caused an infinite loop. But
I’ll test it again. Maybe I did something wrong after
desperately trying other stuff…<br>
I’ll be right back..</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T13:21:53Z2013-06-21T13:21:53ZGo modular for multiple games?<div><p>hmm, no luck.. should we move this to github, open an issue?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-21T13:51:14Z2013-06-21T13:57:04ZGo modular for multiple games?<div><p>This works!!!</p>
<p>In ModuleConnectorConfig – only the receiveEvent is
set!!<br></p>
<pre>
<code>moduleConnector.onChannel('siblingChannel')
.receiveEvent(ModularConnectorEvent.SOME_TYPE);</code>
</pre>
<pre>
<code>[Inject (name='siblingChannel')]
public var siblingDispatcher:IEventDispatcher;
siblingDispatcher.addEventListener(ModularConnectorEvent.SOME_TYPE);
...
siblingDispatcher.dispatchEvent(ModularConnectorEvent.SOME_TYPE);</code>
</pre></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T08:28:05Z2013-06-22T08:53:49ZGo modular for multiple games?<div><p>I noticed that when a ModularConnectorEvent event is dispatched
in both your and my demo, it <em>initializes</em> the event five
times - or less when less modules are added, something I see when I
do a trace() call in the constructor of the event. The mediators
are receiving the event only once, so that's good. I'm sure this
has to do with the inter-modular relaying but was just wondering
how this globally works.</p>
<p>Btw, I'd love to see an extension that makes it possible to use
signals for modular relaying and receiving, wouldn't know where to
start :)</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T09:21:09Z2013-06-22T09:21:09ZGo modular for multiple games?<div><p>@Jeffw: yeah, that's the crappy event system, basically the
event is cloned for each redispatch. It's to make sure the
<code>currentTarget</code> has a dedicated value. If only there was
a way to override that behaviour...</p>
<p>Regarding the signals for modular communication, take a look at
this example:<br>
<a href=
"https://github.com/robotlegs/ModularRL">https://github.com/robotlegs/ModularRL</a></p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T09:21:29Z2013-06-22T09:21:56ZGo modular for multiple games?<div><p>One reason for this is the mediator re-dispatching the
event.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T09:28:49Z2013-06-22T09:28:49ZGo modular for multiple games?<div><p>@creynders yes, I just saw that example, thanks. It doesn't seem
to work with ModuleConnector. Hmm, so many options...</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T09:41:27Z2013-06-22T09:41:27ZGo modular for multiple games?<div><p>@jeffw no it uses solely signals, in which case you don't need
the ModuleConnector. Personally, I like signals for dedicated,
tight communication: view to mediator, abstract service to concrete
service, etc. but not for system-wide communication. Signals are
great because you can add them to the API, which makes the
communication method explicit. Events are better for system-wide
communication because they don't pollute the injector with tons of
mappings (sth which happens easily with signals) but obviously this
is a matter of preference and coding style.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T09:48:03Z2013-06-22T09:48:03ZGo modular for multiple games?<div><p>Does that mean you use both signals and events in one project? I
always tried to stay away from that, but maybe in this case I can
use signals within my module contexts and events for communication
between contexts.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T10:15:45Z2013-06-22T10:15:45ZGo modular for multiple games?<div><p>Yes, I use both. But you need to be very strict about how you
use them, otherwise it becomes a mess. (i.e. signals are only for
<em>this</em> kind of communication and events are only for
<em>that</em> kind of communication. No intermingling!!) It takes
some experimenting to find the approach that feels 'right'.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-22T10:18:41Z2013-06-22T10:18:41ZGo modular for multiple games?<div><blockquote>
<p>I can use signals within my module contexts and events for
communication between contexts.</p>
</blockquote>
<p>That could be such an approach, but as I said, make sure you
don't violate your own rule.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-23T12:26:05Z2013-06-23T12:33:29ZGo modular for multiple games?<div><p>@JeffW Is it possible to add the Starling extension to your AS3
example? I've been trying but had no luck. I'm new to Robotlegs 2
so any advice you can give would help. Cheers</p></div>alanmtag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-24T10:16:12Z2013-06-24T10:19:27ZGo modular for multiple games?<div><p>@alanm I'm not sure if it is possible, I guess it should be. I
am pretty new to RL 2 myself. Have you seen this example? <a href=
"https://github.com/brean/robotlegs2-starling-clock-example/tree/master/src/example">
https://github.com/brean/robotlegs2-starling-clock-example/tree/mas...</a></p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-24T10:16:52Z2013-06-24T10:18:18ZGo modular for multiple games?<div><p>hi again,</p>
<p>I have been thinking about how I can work on different levels
(common, shell, modules) at the same time without having problems
with injections of for instance models into commands that share
code that both modules are using (Ondina's example does not contain
commands and models).</p>
<p>I would like to check if my thoughts are correct.<br>
My shell is responsible for adding and removing modules, and for
letting modules know some values based on the previously shown
module, for instance speed.</p>
<p>The modules have their own views, commands, models, services and
associative mappings.<br>
If the modules share code - in a command, model, service or view -
I write a super class that contains this code and a sub class for
each module with module-specific code.</p>
<p>For instance, I'll have a super startup command for both modules
that will add some views, and each module has a sub startup command
in which I inject their own state model, in which some variables
are set. If the state models share functionality I can extend them
from a super model.</p>
<p>I should not inject models or services into a super command,
because it will give errors.<br>
Unless both modules have mapped this model or service. Is this
correct?</p>
<p>The ModularConnection events are used when I need to change
modules.<br>
For instance, moduleA lets shell know it is finished, so shell can
add moduleB</p>
<p>Does this make sense?</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-24T11:23:58Z2013-06-24T11:23:58ZGo modular for multiple games?<div><p>Hi Jeff,</p>
<p>I’m not quite able to answer your questions right now,
because I’m busy writing a Readme for my demo, which is now
on github:<br>
<a href=
"https://github.com/Ondina/robotlegs-bender-modular-air">https://github.com/Ondina/robotlegs-bender-modular-air</a></p>
<p>Please take a look at it. Your feedback would be
appreciated.</p>
<blockquote>
<p>Ondina's example does not contain commands and models</p>
</blockquote>
<p>Yeah, this demo is concentrating solely on the inter-contexts
communication. I’m trying to keep it as simple as
possible.</p>
<p>Integrating commands, models and services could be the subject
of another demo, based on this one. But, let me finish this first
;)</p>
<p>Hopefully someone else will answer your questions today.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-24T18:30:09Z2013-06-24T18:30:09ZGo modular for multiple games?<div><p>hi Ondina,</p>
<p>I walked through the code in your github commit. You have not
changed much, right?<br>
Nice commenting, great diagrams!</p>
<p>No comments from my side, only thing I can think of is that the
name for ModuleBOrCContext.as may sound a bit messy.</p>
<p>All by all, still a great example for introducing modular
connection.</p></div>JeffW.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-25T09:31:14Z2013-06-25T09:31:14ZGo modular for multiple games?<div><p>Thanks Jeff, I’m glad you like it.</p>
<blockquote>
<p>ModuleBOrCContext.as may sound a bit messy.</p>
</blockquote>
<p>Tell me about it, very messy!! I got stuck at naming it, and
thought I just give it some name to be refactored later. There are
other classes, methods and vars as well, that I’d like to
rename.</p>
<blockquote>
<p>You have not changed much, right?</p>
</blockquote>
<p>Heh, I guess you're saying it jokingly, because I made lots of
changes, actually.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-25T09:49:28Z2013-06-25T09:49:31ZGo modular for multiple games?<div><p>@JeffW Thanks for the link, it helped me a lot with RL2 syntax.
Cheers.</p></div>alanmtag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-25T09:51:28Z2013-06-25T09:51:28ZGo modular for multiple games?<div><p>Hey Alan,</p>
<p>Adding to Jeff’s answer.</p>
<p><a href=
"http://knowledge.robotlegs.org/discussions/examples/20-links-to-robotlegs-v2-articles-examples-demos-utilities-and-tutorials">
http://knowledge.robotlegs.org/discussions/examples/20-links-to-rob...</a></p>
<p>There are a few examples using Starling and an extension (SARS).
Not sure if they are up to date, though.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-27T00:57:03Z2013-06-27T00:57:04ZGo modular for multiple games?<div><p>@Ondina Thanks for your demo.</p></div>alanmtag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-06-27T07:54:25Z2013-06-27T07:54:25ZGo modular for multiple games?<div><p>@Alan My pleasure! I hope it's useful.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274130762013-07-02T07:35:46Z2013-07-02T07:35:46ZGo modular for multiple games?<div><p>I'm closing this for now.</p></div>Ondina D.F.