Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Stopping a custom method  (Read 2436 times)

0 Members and 1 Guest are viewing this topic.

Dan Peach

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 100
    • View Profile
    • Viperante - Game Development
Stopping a custom method
« on: July 05, 2012, 12:53:24 AM »

Good day  :)

So, I have this custom method in the script of my caption window:

Code: WME Script
  1.  
  2. method DisplayCaption(var Text)
  3. {
  4.  var CaptionText = this.GetControl("caption");
  5.  CaptionText.Text = Text;
  6.  this.Visible = true;
  7.  Sleep(5000);
  8.  for(var i=10; i>=1; i=i-1)
  9.   {
  10.    this.AlphaColor = MakeRGBA(255, 255, 255, 25*i);
  11.    Sleep(20);
  12.   }
  13.  this.AlphaColor = MakeRGBA(255, 255, 255, 0);
  14.  CaptionText.Text = null;
  15.  this.Visible = false;
  16.  this.AlphaColor = MakeRGBA(255, 255, 255, 255);
  17. }

So when someone clicks a hotspot, I send some caption text to this method, and the window becomes visible, displays the caption text, waits 5 seconds, then fades out and becomes invisible again.

This works fine initially, but the problem is if a player clicks another hotspot, it just runs this method again, whilst the first instance is still running, which means the window always goes invisible after the first 5 seconds are up. Making sense? Good.  ;)

So, is there a way to cancel the first run through if a player clicks the same hotspot again or clicks a new hotspot, so that there is only ever one instance of this method executing at any one time?

Thanks.

 :)

Dan Peach

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 100
    • View Profile
    • Viperante - Game Development
Re: Stopping a custom method
« Reply #1 on: July 05, 2012, 02:25:00 AM »

Ok, I seem to have solved this problem (for my simple purposes) by unloading the window, then immediately loading it again. Works ok now.  :)
 

Page created in 0.042 seconds with 24 queries.