actionscript 3 - Error with jump function when putting script on movieclip -


i'm having problem jump function platformer engine. i've moved of hit testing onto individual platforms in level, don't have write things out each individual one. problem first movieclip added stage can jumped on to. others make player sink through floor if held down (as should- he's not meant there there's nothing stop him). problem check jump isn't registering on second block. here's code (sorry excessive movieclip(parent) s)

var playerref:movieclip = movieclip(parent).player;  stage.addeventlistener(event.enter_frame, hitupdate); function hitupdate(e:event):void {     if (playerref.hittestpoint(playerref.x,this.y - (playerref.height/2)) && playerref.x + playerref.width > this.x && playerref.x < this.x + this.width && !movieclip(parent).updown) {         movieclip(parent).downmomentum = 0;         playerref.y = this.y - playerref.height;     }      if (playerref.hittestpoint(playerref.x,this.y + this.height) && playerref.x + playerref.width > this.x && playerref.x < this.x + this.width) {         movieclip(parent).downmomentum = 0;         playerref.y = this.y + this.height + movieclip(parent).gravity;     }      if (playerref.hittestpoint(this.x,playerref.y) && playerref.y + playerref.height > this.y && playerref.y < this.y + this.height) {         movieclip(parent).speed = 0;         playerref.x = this.x - playerref.width;     }      if (playerref.hittestpoint(this.x + this.width,playerref.y) && playerref.y + playerref.height > this.y && playerref.y < this.y + this.height) {         movieclip(parent).speed = 0;         playerref.x = this.x + this.width;     }      if (playerref.hittestobject(this)) {         movieclip(parent).groundtouch = true;     } else {         movieclip(parent).groundtouch = false;     } } 

and jump function runs this:

stage.addeventlistener(event.enter_frame, updates); function updates(e:event):void{      player.y += downmomentum;      if(!groundtouch && downmomentum < downmomcap){         downmomentum += gravity;     }     if(downmomentum > downmomcap){         downmomentum = downmomcap;     }      if(updown && !jumping && groundtouch){         jumping = true;         jumptimer.reset();         jumptimer.start();     } }  jumptimer.addeventlistener(timerevent.timer, jumptick); function jumptick(e:timerevent):void{     if(downmomentum*-1 < downmomcap){         downmomentum  -= jumpprog * jumpincrement;     }else{         downmomentum = downmomcap * -1;     }     jumpprog -= 1; }  jumptimer.addeventlistener(timerevent.timer_complete, jumpdone); function jumpdone(e:timerevent):void{     jumptimer.stop();     jumping = false;     jumpprog = 5; } 

i can't find solution this, though suspect it's how checks player touching platform.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -