Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: VEn0m on May 09, 2012, 11:22:07 AM

Title: One script and a lot of sprites
Post by: VEn0m on May 09, 2012, 11:22:07 AM
I'm making a mini game in a quest. On the scene there are 10+ non-interactive sprite entities's images. The one you click on must disappear. Can I somehow make it by using only one script or I'll have to add a script for each of the sprites?

And once more

Code: [Select]
on "Keypress"
{
  if (Keyboard.IsControl)
  {
  Game.Msg("bla bla");
  }
}
- working

Code: [Select]
on "Keypress"
{
  if (Keyboard.IsAlt)
  {
  Game.Msg("bla bla");
  }
}
-not working.

WTF? 
Title: Re: One script and a lot of sprites
Post by: piere on May 09, 2012, 08:26:53 PM
Whats so hard about adding a script to each sprite? It is made automatically, and it just use the

on "LeftClick"
{
this.Visible = false;
}
Title: Re: One script and a lot of sprites
Post by: VEn0m on May 09, 2012, 08:31:07 PM
Quote
Whats so hard about adding a script to each sprite? It is made automatically, and it just use the

on "LeftClick"
{
this.Visible = false;
}

20+ levels with 10+ sprites... I'm to lazy to do it with each sprite :)
Title: Re: One script and a lot of sprites
Post by: Endrit on May 09, 2012, 10:33:45 PM
Quote
Whats so hard about adding a script to each sprite? It is made automatically, and it just use the

on "LeftClick"
{
this.Visible = false;
}

20+ levels with 10+ sprites... I'm to lazy to do it with each sprite :)

LOL
Title: Re: One script and a lot of sprites
Post by: metamorphium on May 10, 2012, 09:07:23 AM
:)) If you name your sprites correctly, you can do:

Code: WME Script
  1.  
  2. for (var a=0;a<10;a = a+1)
  3. {
  4.     var ent = Scene.GetNode("mysprite" + a);
  5.     ent.AttachScript("path to script file");
  6. }
  7.  
  8.  
Title: Re: One script and a lot of sprites
Post by: VEn0m on May 11, 2012, 06:28:32 AM
Thank you very much. That's exactly what I was looking for  ::rock