The Daily Click ::. Forums ::. Klik Coding Help ::. Ordering objects dynamically
 

Post Reply  Post Oekaki 
 

Posted By Message

JoeGP



Registered
  02/07/2012 21:24:42
Points
  82
11th August, 2012 at 11/08/2012 11:26:09 -

I came up with what I thought was a clever way of adding depth to a platforming game I'm working on, but now I've run into a problem. Basically, I've made it so that objects will change perspective based on where they are onscreen. Example, if a cube was on the left hand side it looks like this: [_]] in the middle looks like this: [_] and on the right looks like this: [[_] . The problem I've run into is how to order the objects dynamically. I tried using the layer object and either sorting objects by X increasing or decreasing. But what happens is that the objects will overlap correctly on one half of the screen and then on the other half will overlap in the opposite way than what I need (objects that should go behind go in front.) Any ideas? Thanks!

 
http://www.JoeGP.com

vetmora120



Registered
  07/01/2010
Points
  273
11th August, 2012 at 11/08/2012 11:33:34 -

One way I sometimes order things is use the layer object to sort ALT value decreasing or increasing, depending on your needs. Then, with a start of frame event, set the alterable values of all the active objects that need to be affected. For this I normally use Z, X, or Y as they are rarely ever used and it matches perfectly with the X, Y, Z coordinates.

 
n/a

JoeGP



Registered
  02/07/2012 21:24:42
Points
  82
11th August, 2012 at 11/08/2012 11:41:21 -

OK, yeah, that could work. Is there a way to set an object's value to its exact distance from the edge of the screen? I can't seem to figure that out.

EDIT: Nevermind. I just added an object to remain on the left side of the screen and calculated the difference between it and the object it relates to. However, even that isn't producing the right results. It's still only ordering it correctly on one half of the screen.

I think this is the real question: Is there a way to sort objects in a certain way based on criteria? As in, can I sort objects in different ways based on what side of the screen they are on? Because it seems like all I can do is sort every object the same way.

EDIT AGAIN: Sorry, guys for the multiple edits. Looks like I figured it out. Thanks vetmora120 for setting me on the right path! If anyone's interested, I just set the value based on the distance on the left half of the screen and then based the value on the inverse of the distance on the right half. It works perfectly now!

Edited by JoeGP

 
http://www.JoeGP.com

vetmora120



Registered
  07/01/2010
Points
  273
12th August, 2012 at 12/08/2012 09:32:52 -

Glad you got it working, and glad I could help you out. Yeah, I would have suggested something similar if you hadn't got it working. Thanks for posting the solution also. Nothing worse than people saying they solved a problem but never say how.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click