Touch, move, drop?
violator
Member Posts: 2
I have been looking for the answer to this question but keep coming up empty. If I have an actor in this case says its a red box. i want to be able to touch red box drag it somewhere else on the screen and release it so it stays.
Furthermore I would like to add a puzzle like if i have a circle and square peg and a circle and square hole I want to drag square peg to square hole and release then it checks if the right peg is in the right hole. I think this part I can figure out but i cant get the drag and release thing.
Any help would be great
Furthermore I would like to add a puzzle like if i have a circle and square peg and a circle and square hole I want to drag square peg to square hole and release then it checks if the right peg is in the right hole. I think this part I can figure out but i cant get the drag and release thing.
Any help would be great
Comments
http://gamesalad.com/game/play/49122
@violator: Feel free to download and open up this project to see how it was put together. Some of the things you might want to look into are: tags, collide/overlap, interpolation, touch pressed, and touch released. The tutorials are a good place to go; also, you can search the forums.
All the best.
@violator: You can change the rule so that the correct piece has to be within 20 pixels of the corresponding shape before it snaps in. So, instead of checking for collision/overlap, you can compare the two shapes' x- and y-coordinates using magnitude(). If this value is less than 21 pixels, then use interpolation to snap it in place.
See updated version here:
http://gamesalad.com/game/play/49127
Okay, back to my own game...
http://gamesalad.com/forums/topic.php?id=4839
Thanks for any suggestions.
If I had to work with 10 pieces, here is what I might do. (Keep in mind that I haven't done this yet so it is UNTESTED and might NOT WORK. In other words, try this at your own risk.)
Create two actors: one for the puzzle piece and one for the "hole":
Use synthesis's suggestion here:
http://gamesalad.com/forums/topic.php?id=4297
to create unique cloned actors.
So, within the puzzle piece actor and the corresponding "hole" actor, you might have an integer type attribute called "uniqueID". For corresponding pieces, this "uniqueID" would be the same; for different pieces, different.
You can also change the image of these actors using the "uniqueID" and the technique you described here (where "uniqueID" would take the place of "ImgNum"):
http://gamesalad.com/forums/topic.php?id=2626
In order to see whether they match, I would have two global game attributes: "puzzleUniqueID" and "holeUniqueID". For each actor, create a collision/overlap rule that would have them save their "uniqueID" to the corresponding game attribute.
So, when a puzzle piece overlaps a hole, it saves its "uniqueID" to "puzzleUniqueID". When the hole is hit, it saves its "uniqueID" to "holeUniqueID". If you compare the two and the numbers are the same, it's a match!
----------
The only concern I have, is whether the "hole" would register the collision/overlap and then save its value to "holeUniqueID" (since it's not moving). I would test this first before trying the rest. If collision/overlap doesn't work, I would try a rule that activates when touch enters the actor.
I would love to create a demo for this but I'm falling behind in my own game development right now.
Good luck with this!
http://gamesalad.com/game/play/49484
Have a nice Easter, everyone! I'm off for a few days.