Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Order of objects in scene, and dissolving  (Read 5196 times)

0 Members and 1 Guest are viewing this topic.

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Order of objects in scene, and dissolving
« on: September 27, 2007, 05:16:51 AM »

Mornin',

Is there a way to change the order of the things in a scene using script?

If WME draws things from the top down (in the list), sometimes this causes problems with fading things in and out. For example you fade a sprite in, then you need a different sprite to fade in, in place of the first one, but alas, the second one is drawn before the first one so can't fade in unless the other is inactive. And in my case, I have buttons that the player clicks on, and so I fade in sprites to show the button lit up, but there is no way to know what order the player will click the buttons, so I can't put the sprites in a "correct" order in my scene. Does that make sense?

Alternatively, is there a way to dissolve between sprites? I can fade them in and out, but I can't find a way to fade one in whilst the other fades out at the same time. If the scripts run in a linear fashion, it seems I can only fade out, and THEN fade in, but can't do both at the same time to create a dissolve, unless I'm missing something...?

Being able to do either of these things wold solve the problem I'm facing I think.

Thanks.  8)

EDIT:

Looked into it some more and found MoveBefore and MoveAfter methods, which seem to be exactly what I'm looking for, but it appears they only relate to windows and buttons. Is there some way to use these methods for the scene nodes? I tried to use them but got script error "call to undefined method".
« Last Edit: September 27, 2007, 06:13:08 AM by TheDerman »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Order of objects in scene, and dissolving
« Reply #1 on: September 27, 2007, 08:27:12 AM »

well, I think you're missing for example crossfade. Provided that entity 2 is the one you want to bring in and is nonactive in the Scene Edit, you can do this.


var e = Scene.GetNode("1");
var f = Scene.GetNode("2");
f.AlphaColor = MakeRGBA(255,255,255,0);
f.Active = true;

for (var a=0; a<255; a=a+1)
{
   e.AlphaColor = MakeRGBA(255,255,255,255-a);
   f.AlphaColor = MakeRGBA(255,255,255,a);
   Sleep(1);
}
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Order of objects in scene, and dissolving
« Reply #2 on: September 27, 2007, 08:31:11 AM »

and if you want to change order of nodes, you have to define parent regions which would define the Z-order and then call StickToRegion method for the nodes.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Order of objects in scene, and dissolving
« Reply #3 on: September 27, 2007, 09:45:57 AM »

Hey - thanks for the crossfade thing - that should work I think.

But the "sticktoregion" thing is not working. I made a region, put it at the "top" of the z-order, then called StickToRegion for a certain entity that was beneath another active entity, but nothing happened.  ???

Seems like the MoveAfter and MoveBefore things are perfect for moving the order of scene nodes, but I don't know if that can't be done for whatever reason.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Order of objects in scene, and dissolving
« Reply #4 on: September 27, 2007, 09:51:44 AM »

could you post a script? Also did you make region or region entity?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Order of objects in scene, and dissolving
« Reply #5 on: September 27, 2007, 09:56:12 AM »

Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. var EntityA = Scene.GetNode("entity_a");
  4.  
  5. ////////////////////////////////////////////////////////////////////////////////
  6. on "LeftClick"
  7. {
  8.  
  9. EntityA.StickToRegion("region_a");
  10.  
  11. }
  12.  
  13.  

Says in the docs that we use this method to "lock the z-order value of an entity". So, if an entity has a "value" for the z-order, why can't it be queried and changed?
Logged

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Order of objects in scene, and dissolving
« Reply #6 on: September 27, 2007, 10:00:07 AM »

Also, what about unsticking it? Or is it "stuck" forever?

If I need other entities to be visible over the top of entities that they are currently beneath, how do I do that using this method?

If I have to have a region for each entity, then really it won't be any different because each region will be drawn over the top of the others.

Basically I'm trying to swap out images (entities) that are in the exact same position, and which are really just cutout from the whole background image of the scene. And this is a 1st person game too.

« Last Edit: September 27, 2007, 10:01:50 AM by TheDerman »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Order of objects in scene, and dissolving
« Reply #7 on: September 27, 2007, 10:04:04 AM »

StickToRegion() only works for free entities. The normal entities you use to build the scene in SceneEdit are intended for static objects. If you need to shuffle parts of the scene, I recommend using free entities.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Order of objects in scene, and dissolving
« Reply #8 on: September 27, 2007, 10:12:32 AM »

Actually, I think I can do this with the SetSprite can't I? Have two entities, sort of a "source" and "destination", and swap the sprites when I left click?

I'll try that, and see what happens.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Order of objects in scene, and dissolving
« Reply #9 on: September 27, 2007, 10:21:53 AM »

Sure you can. But you can't do the cross fade that way.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Order of objects in scene, and dissolving
« Reply #10 on: September 27, 2007, 10:33:31 AM »

No, but I've set it so that when you left click, you set the alpha of the destination to 0, change the sprite, fade it in, then set the source entity to the same as the destination. Then when you left click on the next button, the currently visible entity's alpha is set to 0, but because the source is the same as the destination, nothing appears to change. And then we fade in the new sprite. This means the player can click any orde of buttons they like, and each time the old fades out, and the new fades in (in effect, but really only the new sprites fades in). YAY!!!!!!  ::rock  ;D

Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. var Source = Scene.GetNode("source");
  4. var Destination = Scene.GetNode("destination");
  5.  
  6. ////////////////////////////////////////////////////////////////////////////////
  7. on "LeftClick"
  8. {
  9.  Game.Interactive = false;
  10.  
  11.  Destination.AlphaColor = MakeRGBA(255, 255, 255, 0);
  12.  
  13.  Destination.SetSprite("new_sprite.jpg");
  14.  
  15.  for(var i=1; i<=10; i=i+1)
  16.   {
  17.    Destination.AlphaColor = MakeRGBA(255, 255, 255, 25*i);
  18.    Sleep(50);
  19.   }
  20.    Destination.AlphaColor = MakeRGBA(255, 255, 255, 255);
  21.    
  22.    
  23.    Source.SetSprite("new_sprite.jpg");
  24.    
  25.    Game.Interactive = true;
  26. }
  27.  

I didn't even think of the SetSprite thing until I went outside into the cold British morning.   :o

Thanks for the help anyway. The crossfade thing Meta mentioned will definitely come in useful later for me.
« Last Edit: September 27, 2007, 10:39:37 AM by TheDerman »
Logged
 

Page created in 0.053 seconds with 20 queries.