Problem Recycling an actor.
Qorrel
Member Posts: 22
Hi all,
I have a problem with an actor that i need to recycle, So far i have set it up so when the actor goes below a certain point it Sets an scene variable to true. But i think when it goes to far down it no longer works. The actor gets called back into the scene by an spawn actor that when pressed loads the actor at Y=1100, x=touch.x ; any suggestions that could be stopping it form working? (Oh, and constraining it while under the point does not work)
I have a problem with an actor that i need to recycle, So far i have set it up so when the actor goes below a certain point it Sets an scene variable to true. But i think when it goes to far down it no longer works. The actor gets called back into the scene by an spawn actor that when pressed loads the actor at Y=1100, x=touch.x ; any suggestions that could be stopping it form working? (Oh, and constraining it while under the point does not work)
Comments
self.startX
self.startY
In actor, change attributes of self.startx to self position x and same with the y values.
Then when you need the actor to go offscreen, have a rule
when actor (whatever the condition is)
move self.positionY to -100
Then when you want it back, have another rule
when attribute game.bring_actor_back is true
change self.positionX to self.startX and same with the y values.
It is true that once its gone too far offscreen it will be destroyed and that actor is then gone forever so no recycling technique will work.
Now depending on what rules you have in your actor you may need to tweak the above. For instance, if its something that just falls from the top of the screen to the bottom you would need to wrap your rules in a condition, lets say you had an actor that was just accelerating downwards, therefore, you wrap it in;
When self.positionY is > that -100
Accelerate down at 300 etc etc
That way it will fall down but once it hits -100 (just off screen), it will stop accelerating and just sit there. The reset actor attribute is triggered, its position reset and because its now above -100 it will begin to accelerate down again ...
Use that logic to apply to your actors and you should be fine