Need help with game code...

I want to have it so that when the actor is touched and you drag your finger in a direction and let go another actor spawns from the actor you touched in that direction. I have all the spawning down and am happy with it but I am unable to get the drag to work properly... any ideas? the main problem I'm having is that i don't want it to spawn if not a real drag but rather a tap.
Best Answer
-
Photics Posts: 4,172
The trick is to record the starting X&Y points of the touch. Then, upon release, calculate if the release location is far away enough.
Game Attributes...
• game.startX
• game.startY
• game.releaseX
• game.releaseY
If touch is pressed...
change game.startX to mouse.X
change game.startY to mouse.Y
if touch is release
change game.releaseX to mouse.X
change game.releaseY to mouse.Y
...if game.releaseX is greater than game.startX + 25
or... if game.releaseX is less than game.startX - 25
or... if game.releaseY is greater than than game.startY + 25
or... if game.releaseY is less than game.startY - 25
... run behaviors
otherwise... play error sound
This is just a rough outline. I didn't test it, but I think that could be the solution you're looking.
Answers
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
There's also this @tshirtbooth video:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User