Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Changing a sprite image in a layer  (Read 3109 times)

0 Members and 1 Guest are viewing this topic.

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Changing a sprite image in a layer
« 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.  


« Last Edit: May 05, 2009, 05:06:16 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Changing a sprite image in a layer
« Reply #1 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.  

« Last Edit: May 05, 2009, 05:06:42 AM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Changing a sprite image in a layer
« Reply #2 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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Changing a sprite image in a layer
« Reply #3 on: May 05, 2009, 02:47:32 PM »

Thank you, Mnemonic. Filing this thread away in my help folder.  :  )
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  
 

Page created in 0.027 seconds with 25 queries.