Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: eborr on August 05, 2009, 08:50:02 PM

Title: Order of images
Post by: eborr on August 05, 2009, 08:50:02 PM
I have dynamically created 3 entities, each of which will store an image, one of the images is a background, the other 2 should show in the foreground.

I am struggling to get the images to appear in the correct order, EG the background down first and then the other two on top.  However the ordering of the images changes if I vary the X co-ordinate of the background

Code: WME Script
  1. // background entity
  2.  
  3. var backg = Scene.CreateEntity();
  4.  
  5. //foreground
  6. var npc =Scene.CreateEntity();
  7.  
  8. var tre= Scene.CreateEntity();
  9. backg.X = 0;
  10. backg.Y=458;
  11. backg.SetSprite("interface\paper1000.png");
  12.  
  13. tre.X= 0;
  14. tre.Y=468;
  15. npc.X= 50;
  16. npc.Y = 468;
  17.  
  18. npc.SetSprite("theads\furst.png");
  19.  
  20. tre.SetSprite("theads\ron.png")


Any ideas, I am aware that I could solve the problem be creating nodes in scenes, however  this is code that I want to re-use
Title: Re: Order of images
Post by: Mnemonic on August 05, 2009, 09:08:14 PM
Scene.CreateEntity() creates a "free" entity. These entities are sorted by their Y position on screen.
If you want to reproduce adding nodes in SceneEdit, use the AddEntity() method of scene layers.

Code: WME Script
  1. var Layer = Scene.MainLayer;
  2. Layer.AddEntity("some name");
  3. Layer.AddEntity("some other name");
  4.  
Title: Re: Order of images
Post by: eborr on August 05, 2009, 09:17:39 PM
thank you, in these circumstances then answer I think is a combination of CreateEntity and AddEntity, I have worked out a solution by creating a background node in the scene editor, maybe not the most elegant, but it works
Title: Re: Order of images
Post by: Mnemonic on August 05, 2009, 09:25:22 PM
Using these methods you can programatically do pretty much anything you can do manually in SceneEdit. Except adding a new waypoint group, that is.