Game glitches with apparently no reason (interpolation behavior)
I started with GameSalad recently and so far I was enjoying the experience (despite the lack of some basic features), but yesterday I've got into a bug/glitch that I cannot explain and for which I couldn't find an answer here or anywhere online.
I'll try to provide a video capture later, but the thing is pretty easy:
I have an actor that should move left and right on the screen, while moving from the top of the screen to the bottom of a certain amount of pixel when the screen is tapped. The horizontal left right movement is automatic and smooth, while the vertical descent is by steps when I tap the screen.
I can't set colliders on the edges of the screen to make it change direction, since I want this to be like a block I can use to make custom obstacles, all with the same movement, and I don't want each block to go all the way to the edges every time. Basically I need these blocks to create walls with custom gaps for the character to go through.
So I gave this actor an interpolation. I read its X position as first thing, I set an attribute to be equal to this initial position.
Then, in an rule where I check if the actor is still on screen, I interpolate the actor X position to something like "original X" + 100. And it moves right. Perfect.
In the same rule I check if the actor X is in the "original X"+100 position, if so it means it moved, and then I send it back to "original X".
It worked fine, and with ease in/out was looking pretty smooth.
But then I realized I was moving the actor just back and forth in one direction, while I'd need an equal movement left and right from the original spawning position.
And here comes the problem.
I set a boolean attribute called "moved_rt" (moved right) to check if the movement to the right was done, set to FALSE.
All in the same rule (the one checking the actor to be on screen) I then checked if the actor X was equal to "original X" AND "moved_rt" is FALSE, then interpolate to self.x+100.
If self.X is equal to "original X"+100 then interpolate self.x to "original X" and change attribute "moved_rt" to TRUE.
Then if self.X = "original X" AND "moved_rt" is TRUE, interpolate self.X to "original X"-100.
Last if self.X = "original X"-100, interpolate self.x to "original X" and change attribute "moved_rt" to FALSE.
Makes sense, right? Writing it down now just convinces me more that the logic is working.
The problem? When I add these modifications to the rule and I click play to test it, the game area glitches with portions of the gamesalad window messed up inside the preview area (you know the typical screen glitches where various parts of what's on screen are mixed up in random pixels? That). After this glitch, during a couple of seconds, the actors move on screen in a very glitchy way, lagging, moving too fast skipping frames etc... Like a memory issue, maybe?
If I try to test it with the iphone preview app, the app crashes.
The funny part is, if I try to go back removing the new things, the game still do that thing. Luckily I saved a copy on another file and every time I test this I make a new copy. But this is pretty weird, right? Any idea?
Thanks so much to anyone who will try to help me with this.
Wonder Maru: casual games for casual people. www.wondermaru.com