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 an actors sprites  (Read 5087 times)

0 Members and 1 Guest are viewing this topic.

obleo

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
  • Hail to the King baby!
    • View Profile
Changing an actors sprites
« on: March 19, 2003, 04:40:20 PM »

Is it possible to change an actors sprite at runtime?
Say I want to temporarily change the actors 8 Talk sprites to something else.
I noticed a SetSprite method for the Entity object.  Does the Actor object have a similar method, and if so, what is the syntax for using it?

Thanks!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Changing an actors sprites
« Reply #1 on: March 19, 2003, 05:11:45 PM »

If you want to change actor's graphics completely, the easiest way would be to have two .actor files, each referencing different sprites. In the script you'd simply unload the old actor and load a new one (into the same variable).
But if you only want to have special talking animations, there are two possible ways:

1) there is an actor.ForceTalkAnim(filename) method, which will override the talking animation for the subsequent Talk call:
Code: [Select]
actor.ForceTalkAnim("MyCustomTalkAnim.sprite");
actor.Talk("blah blah"); // this talk command will use custom animation
actor.Talk("qwert"); // and this talk command will revert back to default

2) there can be multiple talk "stances" defined in the .actor file.
Code: [Select]
 TALK
  {
    SPRITESET
    {
      NAME = "stance name"
     
      LEFT = "filename.sprite"
      RIGHT = "filename.sprite"
      ...
    }
  }
 
  TALK_SPECIAL
  {
    SPRITESET
    {
      NAME = "another stance name"
     
      LEFT = "filename.sprite"
      RIGHT = "filename.sprite"
      ...
    }
  }
  ...
(the demo "Molly" actor has only one stance defined, without a name, but you can have as many talk stances as you want)

Now, when you call the Talk method, you can specify a list of stances to be used for the talking.
Code: [Select]
actor.Talk("Blah blah", "blah.ogg", 0, "stance1,stance2,stance3");

In the example above, the actor will say "Blah blah", it will play a "blah.ogg" sound, the duration is set to zero (i.e. autodetect) and animations defined in stances "stance1", "stance2" and "stance3" will be used.

To complicate things some more, there are two types of talk stances: normal and special (see the above definition, TALK and TALK_SPECIAL). If you don't specify the list of talk stances when you call the Talk method, the engine will choose random stances. But it will never use the special talk stances, you must explicitly name them if you want them to be used.

So, the conclusion: If you want some special talk animations, either use the ForceTalkAnim method, or add a TALK_SPECIAL section to your .actor file and request this stance to be used in the Talk method.

This is rather advanced topic, so if there's any confusion feel free to ask.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Scarpia

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 77
  • Rich kid trash web designer :-P
    • View Profile
    • junk dot dk
Re:Changing an actors sprites
« Reply #2 on: March 19, 2003, 05:36:27 PM »

Hi Mnemonic. Actually, I think that explanation was pretty clear. Seems like you've really put a lot of thought into that function. I like it. Not too complicated, and I can't think of any feature missing.



Scarpia
Logged

obleo

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
  • Hail to the King baby!
    • View Profile
Re:Changing an actors sprites
« Reply #3 on: March 19, 2003, 10:03:03 PM »

Hey thanks!  That gives me even more ideas.  ::)
Do these "stances" work elsewhere (stand, walk, etc.)?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Changing an actors sprites
« Reply #4 on: March 21, 2003, 06:12:18 PM »

Nope, currently just talking. But with the new sprite caching, everything's possible ;)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.046 seconds with 23 queries.