Comunidad de diseño web y desarrollo en internet online

Movimiento personaje, ¿que hago mal?

Citar            
MensajeEscrito el 12 Dic 2008 11:31 pm
Hago mover un personaje, pero no se x que razón no va a los fotogramas que le pido al moverse (apreto -> y va a un fotograma donde la cara mira hacia ->, lo mismo para el otro lado) aquí esta el código:

onClipEvent (load) {
falling = false;
hitting = false;
gravity = 7;
speed = 6;
jump = 0;
jumping = false;
}
onClipEvent (enterFrame) {
if(!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
_y += gravity;
gravity = 7;
falling = true;
}
if(Key.isDown(Key.SPACE) && jumping == false) {
jumping = true;
luigi.play();
}
if(jumping){
this.gotoAndStop("jump");
this._y -= jump;
jump -= .5;
if (jump<0) {
falling = true;
}
if (jump<-15) {
jump = -15;
}
}
if(_root.ground.hitTest(this._x, this._y, true) && falling) {
jump = 12;
jumping = false;
falling = false;
}
if(Key.isDown(Key.LEFT)) {
gotoAndPlay(2);
_x -= speed;
}
if(Key.isDown(Key.RIGHT)) {
gotoAndPlay(1);
_x += speed;
}
}

Por Juaniix

85 de clabLevel



 

firefox
Citar            
MensajeEscrito el 14 Dic 2008 07:25 pm
Otro que ya solucioné, tendría que hacer los frames en el mismo movie clip (eso creo), pues de esa forma es la única que me anduvo...

onClipEvent (load) {
acceleration = .5
xspeed = 0
yspeed = 0
friction = .25
gravity = .4
jumppower = 10
}
onClipEvent (enterFrame) {
if(xspeed>0){jumppower = 10 + (xspeed/10)}
if(xspeed<0){jumppower = 10 - (xspeed/10)}
if(Key.isDown(Key.LEFT)){xspeed -= acceleration/5}
if(Key.isDown(Key.RIGHT)){xspeed += acceleration/5}
if(yspeed <-.5 and xspeed >0){_root.hit = 0;gotoAndStop(3);} else
if(yspeed >.5 and xspeed >0){_root.hit = 0;gotoAndStop(4);} else
if(yspeed <-.5 and xspeed <0){_root.hit = 0;gotoAndStop(6);} else
if(yspeed >.5 and xspeed <0){_root.hit = 0;gotoAndStop(7);} else
if(yspeed <-.5){_root.hit = 0;gotoAndStop(3);} else
if(yspeed >.5){_root.hit = 0;gotoAndStop(4);} else
if(xspeed <-1){gotoAndStop(5);} else
if(xspeed >1){gotoAndStop(2);} else
if(xspeed >-1 and xspeed <1 and yspeed >-1 and yspeed <1) {gotoAndStop(1);}
_y += yspeed
_x += xspeed
yspeed += gravity
if(_root.hit == 1){
if(xspeed <0){xspeed += friction}
if(xspeed >0){xspeed -= friction}
if(Key.isDown(Key.SPACE)){yspeed -= jumppower;_root.hit = 0} else
if(Key.isDown(Key.UP)){yspeed -= jumppower;_root.hit = 0}
if(Key.isDown(Key.LEFT)){xspeed -= acceleration}
if(Key.isDown(Key.RIGHT)){xspeed += acceleration}}}

Por Juaniix

85 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.