Move an Object to a Hotspot

Started by Ghostlady, Sun 14/07/2024 02:58:51

Previous topic - Next topic

Ghostlady

I have a slider puzzle with 9 squares (hotspots) and 8 of them have an object on them. How can I create a "reset" and have all the objects go back onto the hotspots where they originally came from?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Vincent

My guess is that you can do it with variables. Like you can declare some variables outside at the top of the script:
Code: ags
int ObjPositionX, ObjPositionY;
Then on room_load you set the variable to be the init object position:
Code: ags
ObjPositionX = oObject.X;
ObjPositionY = oObject.Y;
When you need to reset then you can do the opposite:
Code: ags
oObject.X = ObjPositionX;
oObject.Y = ObjPositionY;

Ghostlady

Thank you Vincent for your suggestion.  I ended up doing moves.  I was looking for a quick way, like move object 1 to hotspot 1, without have to figure out the coordinates.

Code: ags
Wait(10);
      object[1].Move(85, 95, 5, eNoBlock, eAnywhere);
      Wait(2);
      object[2].Move(135, 95, 5, eNoBlock, eAnywhere);
      Wait(2);
      object[3].Move(185, 95, 5, eNoBlock, eAnywhere);
      Wait(2);
      object[4].Move(85, 145, 5, eNoBlock, eAnywhere);
      Wait(2);
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Crimson Wizard

Hotspots have WalkToX and WalkToY properties, they are usually meant for character walking to hotspot, but you may utilize these for your purpose:

Code: ags
object[1].Move(hotspot[1].WalkToX, hotspot[1].WalkToY);

Ghostlady

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

SMF spam blocked by CleanTalk