Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: redfox on July 22, 2014, 11:30:09 AM

Title: Scene entity sprite order
Post by: redfox on July 22, 2014, 11:30:09 AM
Is there a way to change the Z-order of entity sprites already in a Scene using a code method? Ideally I would want to jump a clicked on scene entity sprite to the visual top of other sprites.

I see Z-order for windows, buttons, but not for Scene entity sprites.

Thanks
Title: Re: Scene entity sprite order
Post by: ciberspace on July 24, 2014, 07:33:35 AM
Can it be?
Frame object
The Frame object allows you to access the properties of your animation frame. Frame objects can be queried using the Sprite.GetFrame and Sprite.AddFrame methods.

Note: If there is only one subframe, all the subframe methods and attributes also apply to a frame object.



Methods
Actions 
GetSound Returns the sound assigned to this frame.
SetSound Assigns a sound to this frame.
GetSubframe Returns a subframe of this frame.
AddSubframe Adds a new subframe to this animation frame.
InsertSubframe Inserts a new subframe to this animation frame.
Deletesubframe Removes specified subframe from this animation frame.
GetEvent Returns an event assigned to this frame.
AddEvent Adds an event to this frame.
DeleteEvent Removes an event from this frame.

Attributes
Type (read only) Returns always "frame"
Delay The delay of this frame (in milliseconds)
Keyframe Specifies if this frame is a keyframe (not used).
KillSounds Specifies if this frame should stop all currently playing sounds started by this sprite.
MoveX Specifies the X movement applied to the owner object by this frame.
MoveY Specifies the Y movement applied to the owner object by this frame.
NumSubframes (read only) Returns the actual number of subframes if this frame.
NumEvents (read only) Returns the number of events assigned to this frame.
Title: Re: Scene entity sprite order
Post by: redfox on July 28, 2014, 03:12:53 PM
Accessing the sprite frames may be useful for other scenes I am working on, so thank you for that.

But at the moment I am still trying to change the Z-order of the entities in a Scene. 
Title: Re: Scene entity sprite order
Post by: Dan Peach on July 29, 2014, 06:02:47 PM
I seem to remember wanting to do this once. I don't think it's possible. I think I ended up swapping the sprites contained in the entities. That kinda achieves the same thing. :)
Title: Re: Scene entity sprite order
Post by: metamorphium on July 30, 2014, 12:35:33 AM
what's the problem with swapping entity z-orders? You can usually achieve everything similar with StickToRegion()
Title: Re: Scene entity sprite order
Post by: redfox on August 08, 2014, 02:15:22 PM
I have a scene with sprites entities. They are visually items that can be clicked and dragged about, and when released I wanted that item to be on top of the others. But because the Spites are already preset up in the scene, the dragged sprite remains under others.

I thought perhaps I could use the Scene.CreateEntity to make a new version of my sprite item, and delete the original one remaining below? I guess I would need to attach the Script and set the cursor so that item can be dragged about again after.

I shall try working on that method again, but I still need all my movable sprites to remain underneath other graphical location sprites, so those will have to be placed on another layer perhaps.