Lock Moves
Posted: Thu Jun 26, 2014 5:48 pm
I'm moving a bunch of buttons around the screen. Whether or not a button moves depends on if the space it is moving into is empty.
The below script works in terms of properly selecting and moving the buttons to where they should be, but i would like all of the moves to be done at the same time.
I tried using "lock moves" but each button still moves individually when the handler is called.
if it helps to get an idea of what I am doing, this is a game similar to Threes or 2048 where you are picking a direction and all the items in your grid get shifted over.
The below script works in terms of properly selecting and moving the buttons to where they should be, but i would like all of the moves to be done at the same time.
I tried using "lock moves" but each button still moves individually when the handler is called.
Code: Select all
on moveAtom
put "p16,p17,p18,p1,p2,p3,p4" into tRow1
put "p15,p29,p30,p19,p20,p21,p5" into tRow2
lock moves
--take each "pair" of cells from above for comparison
repeat with xx=1 to 7
put item xx of tRow1 into tDestiny
put item xx of tRow2 into tStarting
--if there's a value in B, but nothing in A, then move B to A
if gHex[tStarting]["atom"] is not empty and gHex[tDestiny]["atom"] is empty then
put gHex[tStarting]["atom"] into gHex[tDestiny]["atom"]
put gHex[tStarting]["value"] into gHex[tDestiny]["value"]
put empty into gHex[tStarting]["atom"]
put 0 into gHex[tStarting]["value"]
put gHex[tDestiny]["atom"] into tAtom
put top of graphic tDestiny+24 into tTop
put left of graphic tDestiny+24 into tLeft
move button tAtom to tLeft,tTop
end if
end repeat
unlock moves
end moveAtom