Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Jyujinkai on January 02, 2009, 01:51:50 AM

Title: How exactly do you load a sprite many times on screen?
Post by: Jyujinkai on January 02, 2009, 01:51:50 AM
Mabey i am to tired or somthing but i am unable to see how to load a sprite onto the screen?

All i want to do is use a script to load a single sprite many times in diffrent places on the screen...

Code: WME Script
  1. on "LeftClick"
  2. {
  3. Game.Msg("test");
  4. var temp = Game.LoadEntity("scenes\Room\button.sprite");
  5. temp.X = 70;
  6. temp.Y = 41;
  7. }

This is the code of the left click event i am using... all it is ment to do is load button.sprite and palce it at 70,41?

Title: Re: How exactly do you load a sprite many times on screen?
Post by: sychron on January 02, 2009, 09:23:14 AM
At first glance: You may have to activate or show the entity.
Title: Re: How exactly do you load a sprite many times on screen?
Post by: Mnemonic on January 02, 2009, 10:00:08 AM
Entity is not sprite. Entity is a rather smart scene object and sprite is just one of its properties.
So you either need to load an *entity* from file (see the "Old Guy" in WME demo for reference) or create the entity dynamically in script:

Code: WME Script
  1. var Ent = Scene.CreateEntity();
  2. Ent.SetSprite("scenes\Room\button.sprite");
  3. Ent.X = 70;
  4. Ent.Y = 41;
  5.  

Note that I'm using Scene.CreateEntity(), not Game.CreateEntity(). That will ensure that the entity is automatically destroyed after the player leaves the scene.

Also, entities are part of the scene. If you want to create user interface (judging by the name "button"), perhaps a window would be better suited. You can dynamically create buttons within a window in a similar fashion.