Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Order of images  (Read 1621 times)

0 Members and 1 Guest are viewing this topic.

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 194
    • View Profile
Order of images
« 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
« Last Edit: August 05, 2009, 10:05:31 PM by Jyujinkai »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5679
    • View Profile
    • Dead:Code Site
Re: Order of images
« Reply #1 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.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 194
    • View Profile
Re: Order of images
« Reply #2 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
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5679
    • View Profile
    • Dead:Code Site
Re: Order of images
« Reply #3 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.
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.479 seconds with 24 queries.