The following script is on my sprite. It moves correctly horizontally across the screen, and then flips to the next sprite. The frame always reports 0, though, so the sprite never moves back the other direction as intended.
on enter do
log "enter"
tell event.x,event.y to
call "update_bug"
end
end
on swap_frame do
current_frame = frame
if current_frame==0 then
frame 1
else
frame 0
end
tell event.x,event.y to
call "update_bug"
end
end
on update_bug do
bug_x = event.x
bug_y = event.y
current_frame = frame
log "current frame {current_frame}"
target_x = bug_x
if current_frame==0 then
target_x += 1
else
target_x -= 1
end
target_y = bug_y
target_tile = name target_x,target_y
bug_tile = name bug_x,bug_y
if target_tile!="black" then
wait 1 then
tell bug_x,bug_y to
swap "white"
end
tell target_x,target_y to
swap bug_tile
call "update_bug"
end
end
else
wait 1 then
tell bug_x,bug_y to
call "swap_frame"
end
end
end
end
Am I misunderstanding the use of the frame function?