Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Getting a switch sprite to switch frames  (Read 2283 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
Getting a switch sprite to switch frames
« on: February 15, 2009, 04:16:42 AM »

I have a switch sprite with two frames -- the first is switch down--the second is switch up.

The code on the switch is:

Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. on "LeftClick"
  4.  
  5. {
  6. Switch=this.GetSpriteObject();
  7.  
  8.   if (Switch.CurrentFrame==1) 
  9.     Switch.CurrentFrame=0;
  10.   else
  11.     Switch.CurrentFrame=0;
  12. }
  13.  

It doesn't work.

It's not looping or continuous or pixel precise and I don't use the play animation command. 

Any help is appreciated.  :  )

var Switch doesn't work either--
« Last Edit: February 15, 2009, 04:19:57 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: Getting a switch sprite to switch frames
« Reply #1 on: February 15, 2009, 09:35:06 AM »

Perhaps this is not the best way to do it. Why not just change the image the entity is using?

if(some_condition) this.SetSprite("switch_on.png");
else this.SetSprite("switch_off.png");
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: Getting a switch sprite to switch frames
« Reply #2 on: February 15, 2009, 05:42:55 PM »

Was thinking of that as an alternative but wasn't sure.  Thanks, Mnemonic!!!  : )
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  
 

Page created in 0.072 seconds with 24 queries.