Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Catacomber on May 05, 2009, 02:11:25 AM

Title: Changing a sprite image in a layer
Post by: Catacomber on May 05, 2009, 02:11:25 AM
I have a closeup layer with a background image and then an entity containing a sprite image of a closed bureau.  I want to change the image to an open bureau.  I get this script error:

Call to undefined method 'SetSprite'. Ignored.

This is the script that is part of a puzzle that should change the image.  I tried Layer.GetNode instead of Scene.GetNode, that didn't work. Any help is appreciated:

Code: WME Script
  1. #include "scripts\base.inc"
  2. global Run1;
  3. global Run2;
  4. global Run3;
  5. global Run4;
  6. var x = hud.GetControl("loc");
  7. var Bur = Scene.GetNode("Bureau");
  8.  
  9. on "LeftClick"
  10. {
  11. if((Run1 == 1) && (Run2 == 1) && (Run3 == null) && (Run4==1))
  12. {x.Text = "Tinkle tinkle.";
  13. Bur.SetSprite("scenes\VHouse_Maid\Bureauopen.png");
  14. Run3 = 1;
  15. }
  16. else
  17. {x.Text = "Nothing happens.";
  18. Run3 = null;
  19. }
  20. }
  21.  


Title: Re: Changing a sprite image in a layer
Post by: Catacomber on May 05, 2009, 04:58:48 AM
I solved this by moving things around--so it's still Scene.GetNode in the layer to change an image in the layer. Not a bad thing to know since I couldn't find anything searching the forum.  : )

Code: WME Script
  1. #include "scripts\base.inc"
  2. global Run1;
  3. global Run2;
  4. global Run3;
  5. global Run4;
  6. var x = hud.GetControl("loc");
  7.  
  8. on "LeftClick"
  9. {
  10. if((Run1 == 1) && (Run2 == 1) && (Run3 == null) && (Run4==1))
  11. {
  12. var Bur = Scene.GetNode("Bureau");
  13. x.Text = "Tinkle tinkle.";
  14. Bur.SetSprite("scenes\VHouse_Maid\Bureauopen.png");
  15. Run3 = 1;
  16. }
  17. else
  18. {x.Text = "Nothing happens.";
  19. Run3 = null;
  20. }
  21. }
  22.  

Title: Re: Changing a sprite image in a layer
Post by: Mnemonic on May 05, 2009, 07:02:32 AM
Yes, I think it's always a better idea to query the node just before you're going to use it. In the beginning of the script you can't be sure what parts of the scene are already loaded and ready.
Title: Re: Changing a sprite image in a layer
Post by: Catacomber on May 05, 2009, 02:47:32 PM
Thank you, Mnemonic. Filing this thread away in my help folder.  :  )