Hey everyone, I am having some trouble trying to create a spawner in game an attaching it to my in game object.
When I set the Spawner property on the ini file the spawner is successfully created, but when I try to create with orxSpawner_CreateFromConfig it doesn't work unless I also call orxSpawner_Spawn on the update function.
Is this intended? I tried calling the reset and enable functions, but it didn't work either.
Thanks in advance.
PS: In the API Documentation of orxSpawner_SetParent there is:
Parent structure to set (spawner, spawner, camera or frame) / orxNULL
I assume the second spawner should be object?
Comments
Of course, I just realized that 5 minutes after posting in the forums so I would feel stupid :laugh:
Just wondering now, is there a way to do it only with the spawner.
Yes I suppose there is, but really without attaching it to an existing object, the spawner becomes really hard to access and maintain.
A good pattern suggested by Iarwain is to have a little hierarchy like this:
That way, you can enable/disable the "EmptyObjectThatHasASpawner" object to start/stop the spawning.
The beauty is, no turning on or off a spawner directly. And it's easy to traverse from the "MainObjectOrSprite" to get to the "EmptyObjectThatHasASpawner" so you can work with it.
Thanks for pointing out the doc mistake, I'll fix it asap.
As Sausage pointed out, I personally like going through the orxObject API as much as possible, using wrapping objects to control underlying features, be them spawners, sounds, FXs, etc...
Now, to complete Lydesik's answer, if you want your spawner to automatically handle wave spawning, you'll have to add it to an object in addition to enabling it with orxSpawner_Enable() (no SetEnabled() here :P).
orxSpawner_SetParent() will only set the spawner's spatial parent, ie. it'll follow its parent in space (position, rotation, scale).
If you want a spawner to be activated by an object, you have to add it by calling orxObject_Linkstructure(object, spawner). Now your spawner will be updated by the object, including time distorsion if your object is also linked to a clock.