PDA

View Full Version : moveable boundries



korrupt
January 28th, 2003, 09:35 PM
Ok, here's the dilema...

I have a stick figure fighting game I'm currently working on. I've animated the moves and the walking, ect. But now I wanna make it so the players can only stand on one mc, GameArea.

I tried the script that came with part of the tutorial, but nothing happen:


//
// getBoundLeft(), getBoundRight(), getBoundTop(), getBoundBottom() returns bound
//
// returns the boundry to the game area
//
function getBoundLeft()
{
return GameArea._x;
}

function getBoundRight()
{
return GameArea._x+GameArea._width;
}

function getBoundTop()
{
return GameArea._y;
}

function getBoundBottom()
{
return GameArea._y+GameArea._height;
}

If this way isn't a possible, then I'd just like to limit the players on how high/low they can move.

Anyone with any insight would be GREATLY appreciated.

Thanks in advanced,
KoRRupt

Jubba: Just to make the code easier to read

Jubba
January 28th, 2003, 09:48 PM
Those functions return a value. They aren't supposed to limit anything. What you would do is call the variable in an IF statement check to see the position of the fighter:



if(fighter.MC._x >= GetBoundLeft()){
//do this...
}

korrupt
January 28th, 2003, 09:57 PM
Would I put that in the first frame of the maintimeline?

Also:

if(fighter.MC._x >= GetBoundLeft()){
//do this...
}

would fight.mc be the root and instance name?

_root.hero._x ?

Thanks man

-KoRRupt

korrupt
January 28th, 2003, 09:59 PM
Also how would i stop the hero mc (the main fighter)

if(fighter.MC._x >= GetBoundLeft()){
stop()
}

?

Thanks again

Jubba
January 28th, 2003, 10:07 PM
well it depends on if you are using FMX or F5.

fmx:


fightMC.onEnterFrame = function(){
if(_x >= GetLeftBounds()){
_x = ###
}
}


f5:


onClipEvent(enterFrame){
if(_x >= GetLeftBounds()){
_x = ###
}
}


just replace ### with the Xvalue that you want to place the FighterMC at. Do a seperate IF statement for every funciton