Scripting problem with moving objects

Started by SFG Leader, Thu 13/12/2007 09:27:13

Previous topic - Next topic

SFG Leader

When I try and use this script it, the object (a car) doesn't appear but the game continues.
I have the SetTimer command but the script bellow still doesn't work. I have double checked
all the SetTimer variables and the variables below and they all seem to be correct.
All the script below is in the Repeatedly Execute section of my room and the SetTimer
command is in the Player enters room (after fadein) section.
Code: ags

if (IsTimerExpired(2) == 1) {
  oCar1.Visible = true;
  oCar1.Move(318, 234, 3, eNoBlock, eAnywhere);
  oCar1.Visible = false;
  }

Any thoughts on what I am doing wrong will be greatly appreciated.

Gilbert

The problem is, you used "eNoBlock" for the object movement, so the next "...Visible = false" line will be executed immediately after that, so the object will be turned off immediately before moving.

Depending on your needs, suggested solutions are:
1. Change the movement to eBlock; or
2. If you don't want the movement to be blocking but don't mind the object to stay on screen, just remove the "...Visible = false" line; or
3. If you don't want the  movement to be blocking and still want the object to disappear after moving, in your case you may revise the codes as:
Code: ags

if (IsTimerExpired(2) == 1) {
  oCar1.Visible = true;
  oCar1.Move(318, 234, 3, eNoBlock, eAnywhere);
  }
if (oCar1.Moving==0) oCar1.Visible = false;


Khris

Or, since you're using eAnywhere, just move the car off the screen.
oCar1.Move(320, ...);
Right?

Terrorcell


SMF spam blocked by CleanTalk