Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Changing entity sprites at runtime?  (Read 3158 times)

0 Members and 1 Guest are viewing this topic.

DocBass

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 136
    • View Profile
Changing entity sprites at runtime?
« on: August 22, 2007, 03:50:52 AM »

Is it possible to change the sprite an entity uses at all? Currently we have scenes set up with all possible sprites for certain entities in place, with most of them just inactive. Depending on certain variables, the respective entities are made active or inactive upon entry into the scene.

However would it be possible for something like this to be implemented?

ENTITY {
      NAME="door"
      CAPTION=""
      ACTIVE=TRUE
      X=823
      Y=390
      SCALABLE=FALSE
      INTERACTIVE=FALSE
      COLORABLE=FALSE
      EDITOR_SELECTED=FALSE
      WALK_TO_X=0
      WALK_TO_Y=0
      SPRITE="path\door"+variable+".sprite"
    }

So that the one entity could load a number of sprites when the scene is entered? Obviously this doesn't work currently but would it be possible in the future perhaps? This would allow us to have multiple sprites in a directory such as doorOne.sprite, doorTwo.sprite etc and then if there was a variable entitled "DoorNumber" that stored these strings, it would load automatically. Of course that would also be dependent on if these files are interpreted at runtime whenever you enter a scene...

Currently we just do
if(blah blah == true)
{
     var1 = Scene.GetNode("node1");
     var2 = Scene.GetNode("node2");
     var3 = Scene.GetNode("node3");
     var4 = Scene.GetNode("node4");
     var5 = Scene.GetNode("node5");

     var1.Active = true
     var2.Active = false
     var3.Active = true
     var4.Active = false
     var5.Active = true
}

else if(blah blah)
{
      //similar code with same vars here
}

This seems fairly inefficient to us however to do it like this. Anyway, just curious if anything similar to what I suggested is possible, or if it could be requested for the future.  ;D

Thanks again for all your generosity and kindness Mneumonic.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Changing entity sprites at runtime?
« Reply #1 on: August 22, 2007, 02:23:54 PM »

You can change the sprite at runtime simply by calling the Entity.SetSprite() method.

Code: WME Script
  1. var DoorEntity = Scene.GetNode("door");
  2. DoorEntity.SetSprite("path\closed_door.sprite");
  3.  
                                     

Or am I missing something?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

DocBass

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 136
    • View Profile
Re: Changing entity sprites at runtime?
« Reply #2 on: August 22, 2007, 05:55:32 PM »

I guess I was just wondering if it would ever be possible to do the same thing without having to go through the Scene.GetNode code and be able to do it similar to the first idea listed above, where sprites are loaded automatically based on the scene definitions along with variables. Perhaps I worded my original question poorly.  :P


 
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Changing entity sprites at runtime?
« Reply #3 on: August 24, 2007, 03:02:31 PM »

I can safely say the definition files will never support variables. It somehow doesn't fit the editor concept. I don't think it's a problem though. You can easily script bulk loading, you can dynamically create entities at runtime etc.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

DocBass

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 136
    • View Profile
Re: Changing entity sprites at runtime?
« Reply #4 on: August 26, 2007, 10:36:06 PM »

I can safely say the definition files will never support variables. It somehow doesn't fit the editor concept. I don't think it's a problem though. You can easily script bulk loading, you can dynamically create entities at runtime etc.

Yeah it's cool, it's easy enough as is, thanks! ;D
Logged
 

Page created in 0.106 seconds with 22 queries.