Scene touch constrain issues
I have an iPhone game that the scene is 960 pixels wide, and I need to be able to have my character (an alien floating at the top of the screen) able to shoot where I touch when I have my character fly to the very right part (the second 480 pixels out of a scene that is 960 wide) of the screen.
So just to explain: if I touch anywhere in the first 480 pixels of the scene he will shoot wherever I touch, but when I go rightwards past 481 pixels the camera must not shift and the character will not shoot where i touch but only in the beginning 480 pixels of the scene.
I tried to make the shooter actor stay on the layer that my hud is on but I still get nothing.
So just to explain: if I touch anywhere in the first 480 pixels of the scene he will shoot wherever I touch, but when I go rightwards past 481 pixels the camera must not shift and the character will not shoot where i touch but only in the beginning 480 pixels of the scene.
I tried to make the shooter actor stay on the layer that my hud is on but I still get nothing.
Comments
Sorry but worded very confusing. If I understand you right, you mean when your camera is in the 0-480 you tap there he shoots. If you want to shoot in the 480-960 area you fly there and then when you tap you want him to shoot?
If your problem is that it is not shooting in the 480-960 area it would most likely be because the camera needs to be offset.
So yes, I think that the camera needs to be offset once I enter the 480-960, but I don't know how.
I can send the project if need be to check it out
Well if you want to send it I'll see if I can put it in for you real quick before I go to class. If not here is how to do it.
I'm not sure on the specifics of what you have in your game actor wise so I'll just tell you how I did it in my game that I looked at.
In my Cam actor (which I use for scrolling from side to side) I put a Constrain attribute for a global attribute of Camera X. It constrains the Camera X to Actors self.position x-240. (The actor is in the exact center of the camera)
Then where ever you have it coded to shoot to the touched location have it add Camera X.
That should make it shoot to the right location. Obviously since yours requires both X and Y I assume you will need to do the same for Y. Just make sure that you do a Camera Y constrain to self.position y-160. But you may not need Y, I don't know how your game is set up. (If Y is the standard 360 you wouldn't need it I don't think)
Just to let you know though I'm about to leave and won't be able to get to it until I get back a few hours from now if that's ok.