Does anyone have platform code that also allows the character to walk up and down hills
if (Key.LEFT.isDown(Key.LEFT)and hitest UPground X=+1 Y=+1thats off the top of my head you'll have to sculpt it obvioslyif that even works
with a circle or other shape or a stickman???if a circle try thisif it is a stickman try this
soz try this code for the guyonClipEvent (load) {scale = _xscale;friction = 2;airresist = 1;gravity = 2;jumpamount = 17;speed = 12;onfloor = true;}onClipEvent (enterFrame) {if (Key.isDown(Key.LEFT)) {_xscale = -scale;_x -= walkSpeed;this.gotoAndStop(2);}if(Key.isDown(Key.UP) and onfloor){ jump = true; onfloor = false; yvel = -jumpamount; }if (Key.isDown(Key.RIGHT)) {_xscale = +scale;_x += walkSpeed;this.gotoAndStop(2);}}onClipEvent (keyUp) {this.gotoAndStop(1);walkSpeed = 25;}onClipEvent(enterFrame){ if(xvel < 0){ if(onfloor){ xvel += friction } else { xvel += airresist } } else if(xvel > 0){ if(onfloor){ xvel -= friction } else { xvel -= airresist } } _root.guy._y += yvel if(!_root.platforms.hitTest(_x,_y+1,true)){ yvel += gravity; } else { while(_root.platforms.hitTest(_x,_y+1,true)){ _root.guy._y -= 1; } onfloor = true; yvel = 0; }}
thanks it now works perfect
There is one problem if you jump on a slope you fall through it
You must be logged in to post a reply!