NOOB Actors not repositioning depending on when they move off-screen
hamhose
Member Posts: 12
I am new to Gamesalad, but I am experimenting with some side-scrolling. I do not want to use Wrap-X because I want some actors to be able to fly in and fly out without repeating. As a test, I created a background image 600px wide, and chopped it into 6 sections, each 100px wide. I positioned them side by side, and have them all move the same speed when either the left or right keyboard buttons are pressed. I also set it so that if any one of these actors moves more than 100px to the right of the game width, it is supposed to reposition itself to the left of the left-most actor. Similarly, if it goes more than -100px off the left side of the game, it is supposed to reposition itself to the right of the right-most actor. It worked pretty well, giving me the illusion of a continuous moving background - except that the actors were appearing and disappearing just at the edges of the game. So I made a simple change to their behavior - I set them to move their position when they are 50px off the side of the screen instead of 100px, thinking they would make the move sooner and thus they would never be on-screen when they moved. To my surprise, the whole thing now fails. The actors no longer reposition themselves. I watch as their positions far exceed the 50px limit on either side, and they just keep going. When I change the parameter back to 100px, it all works fine again.
I am sure I have made a mistake or am unaware of some rule I am breaking, but I can't seem to figure out what it is. I am using the Windows version of Gamesalad, Any suggestions would be appreciated.
I am sure I have made a mistake or am unaware of some rule I am breaking, but I can't seem to figure out what it is. I am using the Windows version of Gamesalad, Any suggestions would be appreciated.
Best Answer
-
The_Gamesalad_Guru Posts: 9,922Remember that an actors position is calculated from it's center so you need to take half the width into account.
Answers