Scrolling Background
Hi, i know this may seem to be a simple question and yes, there are tutorials out there teaching you how to do this. However, none of them work for me even though I followed them step by step. I found out that if an actor has a Move behaviour and is placed outside the screen area, it doesnt move. Only when I put it 10 pixels into the frame does it move. Furthermore, as one tutorial mentioned, when the actor goes halfway off the screen, it should create another copy of itself at the other end of the screen so as to create the illusion of a scrolling background. This does not work for me either, maybe the actor is being created but does not move because of the problem I mentioned above. I do not want to wrap X as it does not fit with certain things.
Any help is appreciated, thanks
Comments
How big is your scene, how big is your actor ?
Im using an iPad landscape scene, so 1024 x768. The background is also the same size
When an actor goes more than 500 pixels beyond the edge of the scene it will be destroyed - you are interpreting this as the actor not moving.
Oh, I never knew that.
Thanks! In the tutorial that I saw , the actor did not get destroyed even though it was outside the screen, so i guess that confused me.
Still, the problem persists, is there anything that could solve problem? For example if I split my background image into half (512x768) would it work?
Make your scene larger than 1024 x 768 pixels.
@Socks OK, Ill try it and see, thanks for the help!!
make your background image 2048x768 and tile it, and set it at x1024 y768 and then put a rule inside that says if self.position.X =< 0 then change self.position.X to 1024 and it will loop over and over.
heres a template to help you out, it's very simple.
Agreed with socks! Gamesalad automatically performs screen culling , which basically means it attempts to improve performance by not processing anything outside of the users viewable area. In GS the threshhold seems to be 500px, although I'm not sure if this is officially documented, but its something that I, and @Socks, have noticed through observation. Another way to keep your actor in memory would be to use the loop attribute or to interpolate x attribute. But as socks mentioned, the easiest way is just to increase your scene width, which let's GS know that the actor is still in play and shouldnt be garbage collected.