Dear Forum Members

I have the following problem which I shall try to explain as well as I can.

I have a spelling game for children that comprises of a tree branch with monkeys hanging on it which are holding
tiles that make up letters of the alphabet.

The system extracts a word from a pre compiled list mixes it and then displays the mixed word by setting its letters to the tiles the monkeys are holding.

I have devised a re-arrange system that allows the user to click a tile and then drag it onto another tile, this then results in the tiles being shuffled up to make room for the placement.

I have included a timer that starts when the word appears and lasts for a duration of time, when the timer finishes the next word is displayed etc etc till the end of the round.

I have managed to get this system working but I have hit a the following problem:

If i click and hold one of the tiles and drag it before the timer has finished until it has the tile does not snap back to its starting point.

I am using the in-built moveable option to make my tile sprites moveable.

This is my tile drag behavoir:









global g_SpritePosList, g_TileMemberList, g_gameWord

-- Reference to swap sprite timer object
global gSpellSwapSprTimer

-- Reference to round timer object
global gWordSpellTimer

-- Flag to set that a tile is still being dragged after timeout
global g_timeOutDrag

-- The original Z-depth position of the sprite
property pOrigZposition

-- The original sprite number of this sprite
property pOrigSpriteNum

property targetSprite, startPos, moveIt

global g_letterSprStart, g_letterSprEnd

-- The currently dragged sprite number
global curDraggedSprNum

on beginSprite me

-- Set the cursor to a hand
cursor 260
pOrigSpriteNum = me.SpriteNum
curDraggedSprNum = me.SpriteNum
pOrigZposition = sprite(me.spriteNum).locZ
targetSprite=1

end

on mouseDown me

-- Give the cursor grip!
cursor 290

-- Set the Z-depth position of the sprite
sprite(me.spriteNum).locZ = 500

end

on mouseUp me

-- Release cursor grip
cursor 260

-- Restore the Z-depth position of the sprite
sprite(me.spriteNum).locZ = pOrigZposition

-- Call functions to process users input
setDropTile
placeTiles

end

-----------------------------------------------------------------------------------------
-- Shuffle the arrangement of Letter tiles
-----------------------------------------------------------------------------------------

on setDropTile me

repeat with whichTile = 1 to g_SpritePosList.count
dropDistx = abs(g_SpritePosList[whichTile].locH - sprite(pOrigSpriteNum).locH)
dropDisty = abs(g_SpritePosList[whichTile].locV - sprite(pOrigSpriteNum).locV)

dropDist = dropDistx + dropDisty

-- snap tolerance
if dropDist < 30 then

dropTilePosition = whichTile

put g_TileMemberList

-- delete source tile from list
g_TileMemberList.deleteAt(pOrigSpriteNum-(g_letterSprStart-1))

-- insert source tile into list at dropped position
g_TileMemberList.addAt(dropTilePosition,(sprite(pO rigSpriteNum).member.name))

end if
end repeat
end

-----------------------------------------------------------------------------------------
-- Update the location of the letter sprites
-----------------------------------------------------------------------------------------

on placeTiles me
repeat with n = 1 to g_SpritePosList.count
sprite(n+(g_letterSprStart-1)).member = g_TileMemberList[n]

-- update newly assigned members to correct tile positions
sprite(n+(g_letterSprStart-1)).loc = g_SpritePosList[n]
end repeat

checkResult

end

-----------------------------------------------------------------------------------------
-- Check if the spelling is correct
-----------------------------------------------------------------------------------------

on checkResult
repeat with i = 1 to g_TileMemberList.count
set the itemdelimiter = "_"
set answer = answer& (item 2 OF (getAt(g_TileMemberList,i)) )
end repeat

if answer = g_gameWord then

-- Destroy the current game timer object
deleteOne the actorList, gWordSpellTimer

-- Fire of the swap sprite parent script function
gSpellSwapSprTimer = new(script "SpellSwapSpr_Timer", 43, "Monkey_Correct", 2, "Correct")

end if
end


What I need is to say that when the timer expires set the sprite being dragged back to its position.

Any help would be great as I have spent hours on this and I am sure that someone will know how to do it.

I have tried the following once the timer has expired:


sprite(beingDraggedNum).moveableSprite = false

This sets the sprite back to its position. I then set it back to true when I build the next question.

IF it helps I can e-mail you the code so far.

Thanks in advance

Nubber