Hotspot interaction problem (Solved) :)

Started by Stompybot, Thu 24/04/2008 21:37:41

Previous topic - Next topic

Stompybot

I have started making a game and I have made it so that when someone interacts with a certain hotspot then they will obtain an item. However I want to make it so that the hotspot interacts differently when they click on it for a second time. Anyone know how ???

Matti

#1
You have to create a variable that checks if the hotspot was clicked a second time.

It should look something like that:

Code: ags

int click=0;

interact_hotspotxy(){

  if (click==0) {  //first time hotspot is clicked
    ...
  }
  if (click==1) {  //second and any further time hotspot is clicked
    ...
  }

if (click==0) {
  click++;
}

}

Khris

Or:
Code: ags
...
  if (click==0) {
    ...
    click=1;
  }
  else {
    ...
  }
...


And since 3.0.1 I think, there's Game.DoOnceOnly.

(btw, this is probably the single most often posted question ever and the most common beginner's problem. Realizing that and doing a forum search first shouldn't be that far-fetched. This forum's first page contains at least one thread dealing with this problem.)

Stompybot

Quote from: matti on Fri 25/04/2008 13:25:32
You have to create a variable that checks if the hotspot was clicked a second time.

It should look something like that:

Code: ags

int click=0;

interact_hotspotxy(){

  if (click==0) {  //first time hotspot is clicked


    ...
  }
  if (click==1) {  //second and any further time hotspot is clicked
    ...
  }

if (click==0) {
  click++;
}

}

Thanks my problem is solved now

Stompybot

Quote from: KhrisMUC on Fri 25/04/2008 13:54:14
Or:
Code: ags
...
  if (click==0) {
    ...
    click=1;
  }
  else {
    ...
  }
...


And since 3.0.1 I think, there's Game.DoOnceOnly.

(btw, this is probably the single most often posted question ever and the most common beginner's problem. Realizing that and doing a forum search first shouldn't be that far-fetched. This forum's first page contains at least one thread dealing with this problem.)
Sorry didn't know there was a forum search. Thanks

Khris

There's also a Reply and a Modify button... :)

SMF spam blocked by CleanTalk