Enemies Following Player
Hi i have a space game app and you are a player on the screen and can move it with a joystick. the height of the scene is 320 and the width is 10,000. I have an actor that is constrained to the player that is called collision and when enemies crashes into it the actor is destroyed. i have an enemy spawner that randomly spawns around the screen so enemies come flying in and try to crash into the player from all directions. The player controls the camera and the camera can only move left or right. The enemies follow the player until the camera moves to the right then the enemies just fly a certain distance to the right of the player and explode (instead of crashing into the player) but if you restart the scene and dont cause the camera to move the enemies come flying right at you. The collision is perfectly centered with the player the whole time. But ive found a hint to this matter... when i make the enemy spawner scrollable on the scene then the enemies follow you perfectly the whole time but then the spawner is left behind to the left side which causes the enemies to only spawn on the left... please help ive been trying so hard to fix this issue. Thanks!
Comments
Could somebody please help me with this I'm really stuck
It could be a problem with camera offsets or perhaps its a problem with nonscrollable layers. Or perhaps its a problem with using coordinates 'relative to actor' vs. 'relative to scene'. Its hard to tell from the description. Here are some threads that might help.
http://forums.gamesalad.com/discussion/63148/offset-values-for-scrollable-scene-and-mouse-coordinates
http://forums.gamesalad.com/discussion/63148/offset-values-for-scrollable-scene-and-mouse-coordinates
http://forums.gamesalad.com/discussion/41351/smooth-camera-offset
Many thanks! @rthurman it works i used the third link you had which was constraining the self.position.x and y to the camera but one little issue my camera doesnt move fast enough to keep up with the moving player so i can easily move out of the camera view how do i make it so that the player is always in the camera view?
Normally you would constrain the camera coordinates to the player coordinates.
right that is what i did and the camera follows it fine but the player can easily leave the camera view because its moving faster than the camera is there a way i can resolve this issue? @rthurman
Bump?