I may be wrong, but as magic101hi said, I don't see why you can't use layers to do this (unless that is what you did?). I haven't really tried it, but when I think about it, why can't we just put the "foreground" trees on layer 1, the character on layer 2 and the "background" trees on layer 3? Wouldn't that allow the character to automatically visually appear sandwiched between the 2 tree layers? Or is it simply the tree hitting that's tricky?
If you were to use layers, then have collides on the trees, the spots where the trees seem to overlap you wouldnt be able to get threw because your colliding with both. And spots that the path is over a tree, doing it with layers you wouldnt be able to move threw that because you would still be colliding with it even though its underneath. Def not a simple as you guys think.
It's not as simple as putting the trees in different layers i can assure you, have a go and see what happens:)
Layer 1 tree
Layer 2 character
Layer 3 tree
Now what happens when you walk in front of layer 1 & behind layer 3 trees? You can't walk in front of layer 1 tree because its on top of the character and you can't walk behind layer 3 tree because the character is on a higher layer.
Seems like sciTunes and John get what is going on with the character being able to walk all the way round the trees and pass under and over them.
Interesting... this looks like the start of an isometric RPG.
I think it's easy to create. Here's how I'm thinking I would do it. There are multiple actors for each tree. The top tree actor goes invisible based on the main actor's "Y" position, a duplicate image of the tree is on the ground. (The image could actually be added to the main background to reduce the number of actors.)
The hero actor is in a layer between the top tree images and the bottom tree images. When The hero is below a top-tree actor, that actor goes invisible - alpha zero.
Collisions could also occur based on the actor's "Y" position too.
you have sliced the view to horisontal areas, every area (layer) has own hero actor (which is hidden from screen when not needed), you switch hidden hero actor to correct position (inside scene) when y value of visible hero actor triggers new z-depth (...and of course hide the not needed actor now).
layers make z-depth kind of automatic, just make it to look like the hero actor's vertical movement continues smoothly althought actor actually changes.
utopiangames said: Photics has got it spot on...well done.
Thanks... and you've shown some outstanding creativity. It's easy to create, but hard to figure out. I'm glad that I was able to figure it out. It was more fun that way — excellent thread!
I definitely see the complication in that, very nice work! I think I understand how this works, but I really think that GS should have a simpler way of doing this. This is very important for certain types of games
I know this post is a few days old, but I've been looking for this functionality in GS.
I coded a Flash AS2 demo of a game once where I had multiple characters walking around the screen filled with props as well. To make sure that a character was appropriately behind or in front of other characters/props, I simply did this:
this.swapDepths(_y);
This would give the actor a depth number that was equal to it's y-axis number. So a character that was at y==201 would be in front of a character or prop that was at y==200 or lower. . In my demo, not a single actor was ever destroyed or spawned, I would simply reset their locations if they got killed. The demo ran like butter. Now if only I could do this with GS.
There is object sorting in GS, since you can spawn stuff on top of eachother, but I guess so far we don't have access to it. It would be insanely helpful if we did. GS coders, get on this.
Comments
-Josh
Nice!
Nice job darren!
Layer 1 tree
Layer 2 character
Layer 3 tree
Now what happens when you walk in front of layer 1 & behind layer 3 trees? You can't walk in front of layer 1 tree because its on top of the character and you can't walk behind layer 3 tree because the character is on a higher layer.
Seems like sciTunes and John get what is going on with the character being able to walk all the way round the trees and pass under and over them.
Darren.
quite new gamesalad user here. i have been also looking possibility to have some simple z-depth implementation.
one thing i found (and been myself testing) was this photics idea:
http://gamesalad.com/forums/topic.php?id=8533
i'm now thinking that how serious problem is this:
"even when an actor is destroyed it doesn't clear the RAM"
is there any possibilities to check RAM usage?
what happens if you change the scene, does it clear memory?
Darren.
I think it's easy to create. Here's how I'm thinking I would do it. There are multiple actors for each tree. The top tree actor goes invisible based on the main actor's "Y" position, a duplicate image of the tree is on the ground. (The image could actually be added to the main background to reduce the number of actors.)
The hero actor is in a layer between the top tree images and the bottom tree images. When The hero is below a top-tree actor, that actor goes invisible - alpha zero.
Collisions could also occur based on the actor's "Y" position too.
you have sliced the view to horisontal areas, every area (layer) has own hero actor (which is hidden from screen when not needed), you switch hidden hero actor to correct position (inside scene) when y value of visible hero actor triggers new z-depth (...and of course hide the not needed actor now).
layers make z-depth kind of automatic, just make it to look like the hero actor's vertical movement continues smoothly althought actor actually changes.
I would be interested to know if you accomplished this by some other means.
Yeah it's simple really but i was wondering how to fake it for a while now and had some time to try.
Works really well.
Darren.
Pinball Xmas use the layers solution.
http://itunes.apple.com/us/app/pinball-xmas-hd/id407536738?mt=8
Congrats for your stuff Darren!
Im just pausing game dev now, back in 2011.
www.marcosriffel.com
got just my version working too.
Twitter:rondorocket
Web: rondorocket.com
I coded a Flash AS2 demo of a game once where I had multiple characters walking around the screen filled with props as well. To make sure that a character was appropriately behind or in front of other characters/props, I simply did this:
this.swapDepths(_y);
This would give the actor a depth number that was equal to it's y-axis number. So a character that was at y==201 would be in front of a character or prop that was at y==200 or lower.
There is object sorting in GS, since you can spawn stuff on top of eachother, but I guess so far we don't have access to it. It would be insanely helpful if we did. GS coders, get on this.
This would be great to have in GS but for now i think this way is best because it requires no spawning.
Darren.
EDIT:
Nvm, lol, I reread some of the posts. I like how photics thinks.