Moving actors off-scene
Ignis
Member Posts: 72
I want to use the tactic which was recently discussed (if I recall) to temporarily move actors off the screen, so they don't have any effect on the game... but I want to keep them around, because they appear and re-appear in a pattern. I definitely don't want to Destroy > Spawn > Destroy > Spawn etc.
To do this, I have assigned the actor prototype an attribute "InitX" (integer). I hard-code that value in each individual actor instance to match its starting position in the scene... there is probably a more efficient method, but I don't mind doing this because there won't be more than 10 of these actors in any given scene, and they never deviate from their initial position unless I force them off-scene.
So this is probably a simple question with an obvious answer:
When I force the actor off-scene, can I just use some excessively high X-position integer like 5000? 10000? My test scene is 720 pixels wide, but this might increase. I can't imagine going above even 3000, but 10000 would ensure its disappearance, unless for some reason GS has a problem with this?
To do this, I have assigned the actor prototype an attribute "InitX" (integer). I hard-code that value in each individual actor instance to match its starting position in the scene... there is probably a more efficient method, but I don't mind doing this because there won't be more than 10 of these actors in any given scene, and they never deviate from their initial position unless I force them off-scene.
So this is probably a simple question with an obvious answer:
When I force the actor off-scene, can I just use some excessively high X-position integer like 5000? 10000? My test scene is 720 pixels wide, but this might increase. I can't imagine going above even 3000, but 10000 would ensure its disappearance, unless for some reason GS has a problem with this?
Comments
I don't know the exact distance as it's not a fixed number, but a ratio - it depends on the size of your Actor.
So if you are hiding Actors just off the side of the Scene, that is fine, just don't put them too far away.
That being said, they are still ACTIVE in the Scene. I'm pretty sure that the collision system still has to process them and the graphics system is still rendering them.
This technique just saves you from spawning/destroying which can cause the game to hiccup if those actors are Rule-heavy.
So even though the Actors are off-screen, you still have to deal with them.
You should have a Rule that checks their position, and sets a boolean if they are off-screen or not. Something like "self.hidingOffScreen" . Only collide with that object when that is false, etc...