////////////////////////////////////////////////////////////////////////////////
function OnDropEntity(var DroppedEntity)
{
var NumSlots = 5;
var SlotWidth = 100;
var SlotHeight = 100;
var LetterWidth = 100;
var LetterHeight = 100;
// get the center point of the dropped letter entity
var DropPointX = DroppedEntity.
X + LetterWidth /
2;
var DropPointY = DroppedEntity.
Y + LetterHeight /
2;
// let's assume that the slot entities are named "slot1", "slot2" etc.
// so walk through all the slots...
for(var i = 1; i <= NumSlots; i = i + 1)
{
// query the slot entity from scene
// is the dropped entity over this particular slot?
if (DropPointX >= Slot.
X && DropPointX <= Slot.
X + SlotWidth && DropPointY >= Slot.
Y && DropPointY <= Slot.
Y + SlotHeight
) {
// yes it is; position the letter to the exact position and leave
DroppedEntity.
X = Slot.
X;
DroppedEntity.
Y = Slot.
Y;
// here you may check if the letter is in the correct slot or something
break;
}
}
}