Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: z-Order of an entity  (Read 2956 times)

0 Members and 1 Guest are viewing this topic.

wisemanxxx

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
z-Order of an entity
« on: April 10, 2010, 04:21:07 PM »

I'm designing a puzzle. User can click and drag an object(I'm using sprite entity) to a place. When I click object I want to make this;  object is at top while dragging (top layer) and then when we put it to place it's z-order position must be at bottom. I hope I can tell my problem. I can't solve this problem. If there is a way to change object's layer in script this may be very helpful.

thanks.
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: z-Order of an entity
« Reply #1 on: April 10, 2010, 04:39:15 PM »

There are two approaches to this. If your object is in Main layer, you can simply use StickToRegion(). If it's in different layer, you have to have one extra temporary entity to which you load your sprite while hiding the original and after completion simply hide the temporary entity and show the original repositioned. I use this approach even for dragging / right mouse click rotating entities.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

wisemanxxx

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: z-Order of an entity
« Reply #2 on: April 10, 2010, 05:05:11 PM »

I tried this but I didn't success.
My entity is not a free entity. I put 9 different sprite entities at scene editor.
One script controls all. I made a region on top named "upreg"
All of this at main layer.

in entity's script;

on "LeftClick"
{
global mousex=Game.MouseX-this.X;
global mousey=Game.MouseY-this.Y;
mouseon=true;


this.StickToRegion("upreg");
while (mouseon==true)
{
 this.X = Game.MouseX-mousex;
 this.Y = Game.MouseY-mousey;
Sleep(10);
}

it doesn't work. I guess I'll try your other suggestion.
In fact I plan generate puzzle pieces with script.
Logged

wisemanxxx

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: z-Order of an entity
« Reply #3 on: April 11, 2010, 10:44:35 AM »

As you said I tried use 3 layers.
One is bottom, one is main and other is top layer.
When I draging object I insert a temp. entity in top layer after drag put it to bottom layer.
Thanks for your answer.
Logged
 

Page created in 0.054 seconds with 23 queries.