all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

area help


area help Balloony2
11/4/2006 5:15:39 PM
flash actionscript: I want to make a game like the classic mario games where you jump over the
blocks. when attempting to make this i keep having to put in the seperate axis
in so if i had a block at 93 on the x-axis i have to put

ON(Keypress("<Right>"){
this._x += 5
if(this._x >= 93)
this._x = 93}

and then do the same again and again for the following block so can someone
help me by either telling me a basic code which will stop my character moving
through the blocks from all angles or any other way in which i can do it.
Thanks...
Re: area help kglad
11/4/2006 5:23:30 PM
Re: area help Balloony2
11/4/2006 5:26:51 PM
thanks, but im only a kid learning the basic and when i tried to do the hit
test it worked but still didn't stop my character from every angle, so could
you tell me in more detail because im pretty clue-less. thanks...
Re: area help kglad
11/4/2006 5:36:54 PM
if your blocks are movieclips with instance names block1, block2, ..., block99,
you can use:



ON(Keypress("<Right>"){
this._x += 5
for(var i=1;i<99;i++){
if(this.hitTest(_root["block"+i])){
this._x-=5; // adjust this line to undo your keypress result for you left, up
and down keys.
break;
}
}
}
Re: area help Balloony2
11/4/2006 5:50:44 PM
Re: area help kglad
11/4/2006 6:30:18 PM
try:





ON(Keypress("<Right>"){
this._x += 5
for(var i=1;i<99;i++){
mc=_root["block"+i];
if(this.hitTest(mc)&&this._y<mc._y+mc._height){
this._x-=5; // adjust this line to undo your keypress result for you left, up
and down keys.
break;
}
}
}
Re: area help Balloony2
11/4/2006 6:51:39 PM
i'm not accectly sure how to use that code but it dosn't seem to work propaly.
basically i've created a gravity rule so if you jump you come back down but it
does still not stop when landing on a block but the first code you sent was
perfect.
Re: area help kglad
11/4/2006 6:57:28 PM
Re: area help Balloony2
11/4/2006 7:10:25 PM
them codes are working now but it still doesn't let me land on the blocks from.
i am using the code :

on(keyPress"<Up>"){
this._x += 100}

this still needs some editing but when my bloke comes down he just falls
through the block still.
Re: area help kglad
11/4/2006 9:17:39 PM
in the gravity portion of you code that controls your mario's downward movement
(after jumping), insert the following (assuming that portion of your code is
attached to your mario character).:







for(var i=1;i<99;i++){
mc=_root["block"+i];
if(this.hitTest(mc)){
this._y=mc._y-mc._height;
break;
}
}
Re: area help Balloony2
11/4/2006 10:29:20 PM
Re: area help kglad
11/5/2006 1:13:49 AM
AddThis Social Bookmark Button