View Full Version : Enable MCs to pass behind one another to give simple 3d effect?
tech1495
July 3rd, 2009, 01:47 PM
Hey All,
I'm making a basic 3d platform shoot em up using ActionScript 1.0.
I need a fairly simple script (using swapdepths or something even simpler if possible) to place on a number of different movie clips (6 in total) so that when they rise up the y-axis, and when one MC rises above the other, it moves behind it to give the required 3d effect.
Example:
Elements 1 and 2 have a y-axis reading of 310 are on a lower depth to Element 3 which has a y-axis reading of 280. When Element 3 climbs the screen and reaches and surpasses 310 it should become the Element with the lowest depth.
I'm fairly new to actionscript and am struggling a little here.
All help greatly appreciated.
Rick
bluemagica
July 3rd, 2009, 02:07 PM
sorry, I haven't ever coded in as1, so I don't know what functions are available in there, but if as1 allows swapDepths, then you can just run a for loop on enterframe and swap instances based on their y, since, untill as3, there was no restrictions like the displayList. reading this might help you
http://www.kirupa.com/developer/actionscript/depths.htm
flyingmonkey456
July 4th, 2009, 10:18 PM
switch to as2, there's not that much of a difference.
for this, you would need to program a Z axis. just half the y position and use that as the z position. it isn't necessary to half it, but it makes certain effects easier. then get the z position and use swapdepths(it can't be avoided). there you go, instant 3d. make sure jumping doesn't change the z position. have the height increase be animation only. for bullets, you'll need to set the center much lower than the bullet, so that if the player has just fired the bullet, the center will be at the feet. basically make sure the center of everything is on the ground. if there is anything that you can jump on top of, make sure you have a z correction. just subtract half of the height of the object you're standing on from the z coordinate. do you get it?
SparK_BR
July 9th, 2009, 01:11 AM
switch to as2, there's not that much of a difference.
for this, you would need to program a Z axis. just half the y position and use that as the z position. it isn't necessary to half it, but it makes certain effects easier. then get the z position and use swapdepths(it can't be avoided). there you go, instant 3d. make sure jumping doesn't change the z position. have the height increase be animation only. for bullets, you'll need to set the center much lower than the bullet, so that if the player has just fired the bullet, the center will be at the feet. basically make sure the center of everything is on the ground. if there is anything that you can jump on top of, make sure you have a z correction. just subtract half of the height of the object you're standing on from the z coordinate. do you get it?
:ninja: workarounds! :ninja:
flyingmonkey456
July 9th, 2009, 01:28 AM
:ninja: workarounds! :ninja:
the key word is "work" as in it "works" :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.