Possible to make actor to have certain behavior on different layer?
greyk50@gmail.com
Member Posts: 3
Hi, there is this certain behavior I would like to achieve, which is crucial, is that possible to make actor to have higher z-index if they are closer to the bottom of the screen? I'm trying to make this overlapping actor, but when they are stacking up, it started to looks weird. Please advise. Thanks.
As for the overlapping, can gamesalad create something like image below?
Thanks in advance!
As for the overlapping, can gamesalad create something like image below?
Thanks in advance!
Best Answers
-
Socks London, UK.Posts: 12,822GameSalad users have no direct control over layer order, you can't change the order of the layers at run-time nor can you move or spawn actors to layers other than the one the actor is already on . . . if you want to achieve this sort of thing you need to set up the actors you need on each level and find some way of manipulating them (opacity for example) to make them appear to change layer position . . . or work out a way where a value change on one layer changes an attribute which triggers a spawn behaviour on another layer.
-
Socks London, UK.Posts: 12,822@greyk50@gmail.com
Here's my reply to a similar question posted a few months back, might be useful.
Three layers in this order.
1) Foreground character.
2) Obstacle.
3) Background character.
Both the 'Foreground' and 'Background' are the same character, they follow the same rules, they move together as one . . . but they toggle their alpha channels on and off - so when one is on the other is off (and visa versa).
So when you want the character to walk in front of the obstacle the Foreground character's alpha will be set to 1 (and the Background character's alpha will be set to 0).
& when you want the character to walk behind the obstacle the Foreground character's alpha will be set to 0 (and the Background character's alpha will be set to 1).
Here is a Gamesalad project I'm working on using this method:
. . . . . . .
To automate these alpha channel changes place some 'sensors' around your obstacle, when the character collides with these sensors the relevant alpha channel changes are made.
Hope that makes sense.
Answers
Hero can move 360 degrees, and still applying the z-index behavior. Because I would like all of the actor can move freely (any angle). Please advise, thanks!
But it has a logic flaw as I see it - it only works on stationary enemies - this comes in to effect when you have many moving enemy actors overlapping and your hero and monsters only two layers. So it could mean you have to keep monsters on a grid of layers.
--------------
Hero
--------------
Monster in front
--------------
Object in middle
--------------
Monster at back
--------------
Hero
--------------
Background
Just ideas anyway
Thoughts @Socks?
Maybe use the spawn layer function to move objects up and down layers . . . .?
I just mean that when you spawn an actor you can define where it is spawned within the layer, so you might be able to use than functionality to dynamically shuffle your actors around, just a thought . . . .
I am not sure how you would do if there was fisticuffs and 6 actors were overlapping.
But I thought about it last night and came up with a solution but thought it had a big hole in it.
Hero A
--------------
Monster 1A
--------------
Object A
--------------
Monster 2A
˅˄˅˄˅˄˅˄˅˄˅˄˅˄˅˄˅˄˅˄˅˄
Monster 1B
--------------
Object B
--------------
Monster 2B
--------------
Hero B
--------------
Background
The way above everything can be in front or behind.
But I did thing where say we have a horizon level
Top layer = Hero A + Monster 1A
----------------------------------
Sub layer = Object A/B + Monster A/B (depends on Y value)
Thinking now you already have the layer order as well to work with perhaps it could work with that as a variable added in.
Hmmm, interesting...
http://www.deepblueapps.com/double-dragon-template/
"FULL layers, hero can go in front and behind and even in between enemies and also the enemies can go in front and behind each other."
So greyk50@gmail.com if you want you get a sample project that has the code already done over at @DeepBlueApps for 25 Pound.
However, thanks for the very insightful and helpful advise, @matarua and @Socks, you 2 are awesome, haha. Do you mind if I add you both as facebook friends? lol
Thanks!
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page