How do I make a certain picture above other pictures at times and below them at other times?
(I want car.png to be on top of obstacle1.pgn when the car's below the obstacle, and behind the obstacle when the car is above it.)
I don't need a lengthy script, just the code for dropping and raising a picture on the screen, giving it picture priority over one picture and less over another.
Also, why can't I seem to horizontally tile images without there being a small gap between them, is there a way around this, its been pretty important in the past too
Ok, I fixed the horizontal part, when i rendered to swf it looked fine, just didn't look right in the test renderer great!
Maybe there is something more I need to learn about flash so I can just implement my ideas by coding?
Last edited by Seas_Comander; 01-20-2007 at 10:28 AM.
This is what I have now, but it still doesn't work... new_blockade2 is a clone of blockade2 and car is just itself. I have been unsuccessful at swapping depths of anything, especially this clone. They're slightly off center so I've had to add around 50 Y and 50 X to the car through the code. However.... after tracing car.y and newblockade.y inside the first if here, I see that when the blockade is greater Y there is no swapdepth that I can see
Code:
if (new_blockade2){
if ((car.y+46) < (new_blockade2.y)) {
car.swapDepths(new_blockade2);
}
}
Last edited by Seas_Comander; 01-24-2007 at 12:59 AM.
Well, I'm not sure I got your logic of swapping as you show only tiny part of you code. It looks like your code checks at new_blockage creation time if it should swap with the car (3'rd post code) It should happen every frame and somehow you should keep track which one is on top.
Could you outline your game logic little more like:
- do you have more than 1 obstacle on the screen ?
- if more than 1 then can those obstacles overlap ?
anyway, it might be easier to handle correct swapping if you use a layer that contains your obstacles and variable that would hold information which one, layer or car, is on top. Even with layer you still check car vs. obstacle y but swapping is only done with car and whole layer...
But hmm... where clones go? to the movie/layer where the original one is/was??
Here is one example how to do car & obstacle swapping.. (no layers or multiple obstacles yet) See starting script & action.
edit: one idea came to my mind... it seems that you want car to be behind that "top" part of obstacle.. how about making obstacte on two parts, "tops" that would be in topmost layer and "collision" parts that would be in "bottom" layer?
And car in between them.? -> no swapping at all.
This at least swaps depths, I didn't know you had to specify the layer, so I added that in there. Now the problem with it is it blinks on and off...
Code:
if (new_blockade2){
if (((car.y+46) < (new_blockade2.y))) {
car.swapDepths(layer2);
}
}
I tried what you gave me sorda, using 4 ifs, one for when greater than and one for when lesser than, which I thought would work, and it just stayed on top all the time again for some reason?
Code:
if (new_blockade2){
if (((car.y+46) < (new_blockade2.y)) && (is_on_top=true)) {
car.swapDepths(layer2);
is_on_top=false;
}
}
if (new_blockade2){
if (((car.y+46) < (new_blockade2.y)) && (is_on_top=false)) {
car.swapDepths(layer2);
is_on_top=true;
}
}
I'm trying to make the car behind the obstacle(above it visually) and in front of the obstacle(below it visually) for those just now reading, and my site is listed with the latest build always.
Last edited by Seas_Comander; 01-24-2007 at 06:31 AM.
This at least swaps depths, I didn't know you had to specify the layer, so I added that in there. Now the problem with it is it blinks on and off...
You do not have to have a layer, It just can make sometimes easier to just swap 2 objects and you know then which one is on top etc...
Originally Posted by Seas_Comander
I tried what you gave me sorda, using 4 ifs, one for when greater than and one for when lesser than, which I thought would work, and it just stayed on top all the time again for some reason?
Code:
if (new_blockade2){
if (((car.y+46) < (new_blockade2.y)) && (is_on_top=true)) {
car.swapDepths(layer2);
is_on_top=false;
}
}
if (new_blockade2){
if (((car.y+46) < (new_blockade2.y)) && (is_on_top=false)) {
car.swapDepths(layer2);
is_on_top=true;
}
}
Some typo I quess... you have both Y comparisons using "<" less than expression later one IF used originally ">"
Anyway, if you want I can have a little peek on your movie to check out what bugs if you attach the movie.