is there a way to provide "snapping" of draggable elements during game play?
xyloFUN
Member Posts: 1,593
Hi,
i am wondering if I could "help" a user drag an object to the right place by snapping it to the correct location if released close enough?
If this is possible, could someone please brake down the process so that a simple person like me can understand it?
thank you
i am wondering if I could "help" a user drag an object to the right place by snapping it to the correct location if released close enough?
If this is possible, could someone please brake down the process so that a simple person like me can understand it?
thank you
Comments
http://gamesalad.com/forums/topic.php?id=1894#post-10370
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
If the item your dragging touches inside the transparent actor, upon release, you change the moving actors X,Y positions to the X,Y co-ordinates at the centre of the transparent actor... thus snapping it to the new location.
Theres probably more mathematical ways of doing it, but the system explained above should work.
OK, back to Chunkypixels ....
yes, I like that because that is exactly what I need ... now could you/would you/please do explain how to swap coordinates? I am old and want to figure that out while i still breath
two game.Attributes: (both real type)
whereX
whereY
(I also have a pickIndex to track which drag-able actor is active)
in the prototype of the final placement actor in the grid.:
[Rule] Any
when Actor overlaps/collides with actor of the type
(add/select all possibles from the list)
---change.Attribute game.whereX to self.Position.X
---change.Attribute game.whereY to self.Position.Y
(then drag instances of that actor to the screen)
on the individual drag-able actors:
[Rule]
when touch is pressed
---change.Attribute game.pickIndex To: the appropriate #
[Rule]
when game.pickIndex = #
--[Rule]
when touch is inside
--constrain attributes for drag
--[Rule]
when touch is released
---[Rule]
when actor overlaps/collides with actor with type
---changeAttribute self.Position.X to game.whereX
---changeAttribute self.Position.Y to game.whereY
---Timer after 0.1 second change the whereX and whereY to 0
---Timer after 0.2 second change pickIndex to 0
(had this working in 8.9 without the timers... but 0.9 is so fast you need them to allow for change events)
Sounds complicated... but once I had one working right... I just dragged behaviors to myBehaviors... and back into editor as needed and only had to change pickIndex # and collide type.
MH