Problem creating a "Wrap" With Interpolate - a HArd One, Gurus please come!
Hello Guys, how are you?
I created a Wrap (Like Wrap function of Gamesalad, that if you go to the right… you will appear in the left..) With Interpolate.
I have 2 images, that need to move aligned and Wrap.
My rules (Of both objects) are like this:
If Position Different to 0
Interpolate to 0 at a Constant Speed.
Otherwise (If Position is equal to 0)
Change Position to Other Object + size With of that object
This would make it warp, if the object is moving from right to LEft.
But.. Once in like 20 - 30 games… The thing don't work, and they both stay in the same places, and and Wrap from half of the screen
Please help if you figure out a better method!
Thanks
I created a Wrap (Like Wrap function of Gamesalad, that if you go to the right… you will appear in the left..) With Interpolate.
I have 2 images, that need to move aligned and Wrap.
My rules (Of both objects) are like this:
If Position Different to 0
Interpolate to 0 at a Constant Speed.
Otherwise (If Position is equal to 0)
Change Position to Other Object + size With of that object
This would make it warp, if the object is moving from right to LEft.
But.. Once in like 20 - 30 games… The thing don't work, and they both stay in the same places, and and Wrap from half of the screen
Please help if you figure out a better method!
Thanks
Comments
Or maybe I can figure it out with interpolate, have to think more on it.
Matt
Sometimes it Leaves a Little Space in the Middle.
but some Rare times, it doesn't work.
Matt
If it was that, didn't work
Sorry,
Matt
Cheers and thanks for your help.
you 2 actors instead of 1
then instead of interpolating back to your 0 point on the right, interpolate back to the 0 point + 1/2 the width of actor 2.
i.e. when actor 1 goes offscreen, actor 2 will be onscreen, and interpolate actor 1 to behind actor 2. This should loop much nicer....if you get what I mean.
Thanks.
Btw, I have 2 actors, but both going to 0.
the code for the wrapping should work in theory....
The thing with interpolate is just that, it interpolates. It does a lot of guessing and isn't precise. It might be that it's skipping the value you have the trigger set at, so make it so that it triggers on anything past that value.
"=" alone doesn't work over 1/2 the time in my experience.
At High Speed dosnt work perfect.
Now I will test it on the MAx Speed I will use in my game (Is Less thatn the high speed I test in GamesAlad and make me have problems), and see if sometimes I have problems or not.
Cheers.
This first one uses 1 background and spawning/destroying with Move.
In the background on screen put:
Move attribute Dir. 180
Rule
When attribute self.Position.X <240
Spawn Actor
Position self.Position.X + 480
Rule: when self.position.X < -241
Destroy this actor
The second one, uses Move as well. Use 2 background frames, the edge of the first one in the middle of the screen, the second next to it.
Move attribute Direction 180
When self.Position.X = 240
change attribute self.Position.X = 719
Put this in both of the actors' Rules.
A third thing to consider is using your Ruling but instead of Interpolate, try using a negative number with linear velocity.
Hope that helps.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
The only way i could think of is accessing the scene.layers and comparing the self.x position of each image and using it as a rule.
ex:
if image1.position.x = 240; <--(half of screen)
--->interpolate image2 to -240; <--image 2 x position is at 720
if image2.position.x = 240; <--(half of screen)
--->interpolate image3 to -240; <--image 3 x position is at 720
if image3.position.x = 240; <--(half of screen)
--->interpolate image1 to -240; <--image 1 x position is at 720
relocate images when outside screen
if image1.position.x = -240;
-->change attribute position.x = 720;
then do the same with image2 & image3.
-drahc
Im doing with the method you say.
It works fine at small speeds, I change a little my game speed and will test if now there is non problem.
Thanks to all, gyro, I want to do it with interpolate.
Cheers
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
It was BEcause of performance, thanks for your help.
NOw I Make it Move… and didn't affect performance.
I have 6 actors that make this:
They Warp in x, and they only have one rule:
Change: Self.motion, linear velocoity X to -GameSpeed/One number..
And it works great, and again, didn't affect performance at all.
Lol people talk to much about non movable actors and interpolate that I was a little Maniac..
Cheers.
It wont effect much if you have only have a few movable actors.
@Mago
I ended up using wrapX as well as i noticed that i dont have much gain using interpolate and i dont want to gamble having a gap between images. So far still stable at 60fps with 3-4 256x1024 movable actors.