Having problems with sidescrolling leapfrog effect
alexconsinc
Member Posts: 54
Hey,
I have started working on a new project and I am having probs with the sidescrolling leap effect (background leaps to the other side when hits a certain point). I tried translating this Lua code:
function scrollCity(self,event)
if self.x < -568 then
self.x = 568
else
self.x = self.x - self.speed
end
end
self is the background
For self.speed, I created an actor attribute (integer) but later changed my mind and used the move behaviour instead.
Here are some screenshots of my GameSalad code:
http://imgur.com/wZpnPqN,abI9AUB
What I want it to do is scroll infinitely and when it goes to -568 on X, to leap all the way back to 568 X.
-The background moves
-The background goes all the way off the screen
-It doesn't change is position
What am I doing wrong?
I have started working on a new project and I am having probs with the sidescrolling leap effect (background leaps to the other side when hits a certain point). I tried translating this Lua code:
function scrollCity(self,event)
if self.x < -568 then
self.x = 568
else
self.x = self.x - self.speed
end
end
self is the background
For self.speed, I created an actor attribute (integer) but later changed my mind and used the move behaviour instead.
Here are some screenshots of my GameSalad code:
http://imgur.com/wZpnPqN,abI9AUB
What I want it to do is scroll infinitely and when it goes to -568 on X, to leap all the way back to 568 X.
-The background moves
-The background goes all the way off the screen
-It doesn't change is position
What am I doing wrong?
Comments
i believe if you make it move forward and then back to the edge of the scene, you'll get your result. Just make the screen size that big. I mean at least make it 568*2.
or rather what i figure out, is that your player is on the edge of the screen. Keep it upfront and move the camera too, accordingly and u should be through with this. I don't see much of an issue in here.
function scrollCity(self,event)
if self.x < -284 then
self.x = 284
else
self.x = self.x - self.speed
end
end
I've used 284 because it would be the centre of the image/actor.
I have an example where I'm scrolling 3 backgrounds which I can send later if you're still having trouble.