Hello everybody,
Here I go again with my philosophical questions...
I am giving Scroll a go because I realized I basically was doing that functionality pretty much anyway.
So I find myself with this problem: It seems to me that the
only supported way of creating ScrollObjects and have them properly initialized is via the main application class (i.e. the one that has the Init, Execute, Update, etc). This is a bit inconvenient because many times I am inside of an object, say the player, and I want to spawn bullets directly from there.
I know I can simply make the main application be a singleton and call the CreateObject from the outside, but this solution seems rather ugly. Is there a good reason to not have CreateObject be a static method, or have another way to create ScrollObjects that is more elegant? Am I missing something?
I can get around this problem, but I wondered what people would think.
Thanks a bunch!
Comments
Is the only way around this to create boiler-plate classes that extend my bullet to have a 1-1 mapping?
Cheers,
Hi duenez, I like your questions and I hope you don't mind my answers!
Only a small detail: your main application is already a singleton, that's the nature of Scroll (and that's also how ScrollEd can be embedded in your own game).
You simply need to call CreateObject on that instance, something like:
As long as we already have a singleton, mixing static and non-static methods would get a bit messy.
There are two options to do the mapping, the old one and the new one since binding hierarchy support has been added to Scroll, earlier this year.
Let's look at the old one first (assuming your C++ class is called MyBullet):
The new one, now:
Any orxOBJECT whose config section inherits from [Bullet] will now be bound to the C++ class MyBullet, unless explicitly redefined with a ScrollBindObject<>() call.
Does it make sense?
Cheers!
I saw Scroll was already a singleton after posting, but I still wanted to see what you said. I am using the GetInstance() to create object from all over my code
As for the mapping, I like the way it is done and the way you describe it. Cool!
I seem to be missing something because my Scroll derived class doesn't call the Update function after Execute, nor after StartGame. Which is the magic call to have Orx start calling the Update function?
Cheers,
If you have some code to show me, I could be of better help I think.
http://pastebin.com/6dFMxaMn
Thanks a bunch
You'd think a sensible compiler would warn you about that!
PS: You're using a pointer instead of a reference for the parameter.
PS: I saw you were using rand(), there's a few orxMath_GetRandom*() functions with different types if you ever need them.