Spawn actor on touch issue. Please help!
8bitninja
Member Posts: 367
I'm making a simple block stacking game that spawns a new block when and where you touch the screen. I have a tall scene with a touch area actor that is stretched from the bottom to the top. Everything works great until the blocks reach the top of the initial screen and my camera control actor moves to its second position. Here is where the problem is occurring. After the camera moves to its second position when I touch the screen the block actor no longer spawns where I touched. Instead it spawns way below where I touched.
please, any help is appreciated. Thanks!
Comments
You can divide your viewable camera locations into regions so that when the camera goes into the second one, you can let the game know (maybe set an attribute like game.whichcamera to 2) to adjust your spawns.
Mathtap.com (Android) | Fridgemanager.com (Android) | Breakoutofspace.com (Android)
Touch will always be calculated by the position on the screen of your device.
Spawns will happen relative to the scene as a whole.
If you move your camera, these two things go out of sync.
To avoid this problem, calculate how much the camera has moved by and add (or subtract) that from the touch location.
E.g. Camera has moved up 200px, spawn at touch.y+200
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
You need to take into account the camera's origin. So do
game.Touches.Touch 1.Y + scene.Camera.Origin.Y
Fortuna Infortuna Forti Una
@Summation @Armelline thanks guys, that totally makes sense.
BRUNKT.com
Follow me at: Twitter - Instagram
Games and Templates
Appstore
Awesome, @Lovejoy that sounds somewhat easier, I'll give it a try. Thanks you guys!
BRUNKT.com
Follow me at: Twitter - Instagram
Games and Templates
Appstore
@Lovejoy Thanks again, it worked perfectly!
BRUNKT.com
Follow me at: Twitter - Instagram
Games and Templates
Appstore
Np
Fortuna Infortuna Forti Una