problema clásico de la plataforma

  • ryrocks
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Feb 13, 2009
  • Mensajes: 6
  • Status: Offline

Nota Febrero 22nd, 2009, 5:10 pm

¡Eh!,
Tengo un personaje en el escenario (_ball_mc), que se controla con las teclas de flecha. También tengo un movieclip rectángulo en el escenario (este). Quiero que este movieclip rectángulo para actuar como una plataforma de bloque. es decir. Cuando el personaje salta ontop de que se puede caminar a través de ella, si entra en lo de la izquierda no puede mover hacia la izquierda más, mismo con el lado derecho.

Estos clips de película no se están creando en tiempo de ejecución, están en el escenario.

Mi punto de registro del personaje es la parte inferior derecha,
mi punto de registro del bloque es la parte superior izquierda

Ive utilizado el enterFrame siguiente con no mucha suerte. Detener el carácter de seguir avanzando, cuando entra en el bloque parece estar bien. Im teniendo problemas para que él a la tierra en el bloque sin entrar en conflicto con la leftDown y consumado.

Como se trata de un elemento de juego comunes, me imagino que debe haber algún tipo de documentación al respecto?

Código: [ Select ]
if (_findStageInstances)
            {
                _ball_mc = parent.getChildByName("ball_mc") as MovieClip;
                _findStageInstances = false;
            }
            
            if (_ball_mc.hitTestObject(this) && _ball_mc.x >this.x)
            {
                _ball_mc.rightDown = false;
            }
            if (_ball_mc.hitTestObject(this) && _ball_mc.x > (this.x + this.width))
            {
                _ball_mc.leftDown = false;
                _ball_mc.x +=1; //move ball away from block, otherwise Rdown and Ldown are disabled and it gets stuck
            }
            if (_ball_mc.hitTestObject(this) && _ball_mc.y < this.y)
            {
                _ball_mc.falling = false;
                _ball_mc.jump = false;
                _ball_mc.y = (this.y);
            }
  1. if (_findStageInstances)
  2.             {
  3.                 _ball_mc = parent.getChildByName("ball_mc") as MovieClip;
  4.                 _findStageInstances = false;
  5.             }
  6.             
  7.             if (_ball_mc.hitTestObject(this) && _ball_mc.x >this.x)
  8.             {
  9.                 _ball_mc.rightDown = false;
  10.             }
  11.             if (_ball_mc.hitTestObject(this) && _ball_mc.x > (this.x + this.width))
  12.             {
  13.                 _ball_mc.leftDown = false;
  14.                 _ball_mc.x +=1; //move ball away from block, otherwise Rdown and Ldown are disabled and it gets stuck
  15.             }
  16.             if (_ball_mc.hitTestObject(this) && _ball_mc.y < this.y)
  17.             {
  18.                 _ball_mc.falling = false;
  19.                 _ball_mc.jump = false;
  20.                 _ball_mc.y = (this.y);
  21.             }


Cualquier ayuda sería muy apreciada!
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Febrero 22nd, 2009, 5:10 pm

  • ibrabdo
  • Novice
  • Novice
  • Avatar de Usuario
  • Registrado: Feb 23, 2009
  • Mensajes: 29
  • Status: Offline

Nota Febrero 23rd, 2009, 5:27 am

probar este código, pero lo escribí usando actionscript2 no sé si va a ayudar si u u traducir a actionscript3 pero su trabajo:
tienen 2 u objetos de la bola (ball_mc) y el bloque (piso)
Este código para la ball_mc:

onClipEvent (carga) (
VelX = 0;
Mente = 0;
AccY = 3;
PosX = _root.ball_mc._x;
PosY = _root.ball_mc._y;
suelo = 530;
)
onClipEvent (enterFrame) (
VelX = VelX * 0. 7;
+ = AccY mente;
PosX + = VelX;
PosY + = mente;
if (PosY> = tierra) (
Mente = Math.abs (mente) * 0,4;
PosY = tierra;
if (Key.isDown (Key.SPACE)) (
Mente = -45;
)
)
if (Key.isDown (Key.LEFT)) (
VelX = -15;
)
if (Key.isDown (Key.RIGHT)) (
VelX = 15;
)
_root.ball_mc._x = PosX;
_root.ball_mc._y = PosY;
if (_pare not.Floor.down = 1) (
esto. suelo = 530;
)
)

Y este código para la planta:

onClipEvent (carga) (
abajo = 1;
)
onClipEvent (enterFrame) (
if (_pare not.ball_mc._y <= this._y & &
_pare not.ball_mc._y> (this._y - 50) & &
(_pare Not.ball_mc._x + 10)> & & this._x
_pare not.ball_mc._x <(this._x + this._width)) (
_pare not.ball_mc.ground = this._y;
abajo = 0;
) else (
abajo = 1;
)
)

Pruébelo en Actionscript 2
  • ibrabdo
  • Novice
  • Novice
  • Avatar de Usuario
  • Registrado: Feb 23, 2009
  • Mensajes: 29
  • Status: Offline

Nota Febrero 23rd, 2009, 5:30 am

Este código de la ball_mc:
Código: [ Select ]
onClipEvent(load){
    VelX = 0 ;
    VelY = 0 ;
    AccY = 3 ;
    PosX = _root.ball_mc._x ;
    PosY = _root.ball_mc._y ;
    ground = 530 ;
}
onClipEvent(enterFrame){
    VelX = VelX * 0.7 ;
    VelY += AccY ;
    PosX += VelX ;
    PosY += VelY ;
    if(PosY >= ground ){
            VelY = Math.abs(VelY) * 0.4 ;
            PosY = ground ;
            if(Key.isDown(Key.SPACE)){
                VelY = -45;
            }
        }
    if(Key.isDown(Key.LEFT)){
        VelX = -15 ;
    }
    if(Key.isDown(Key.RIGHT)){
        VelX = 15 ;
    }
    _root.ball_mc._x = PosX ;
    _root.ball_mc._y = PosY ;
    if( _parent.Floor.down = 1 ){
            this.ground = 530 ;
        }
}
  1. onClipEvent(load){
  2.     VelX = 0 ;
  3.     VelY = 0 ;
  4.     AccY = 3 ;
  5.     PosX = _root.ball_mc._x ;
  6.     PosY = _root.ball_mc._y ;
  7.     ground = 530 ;
  8. }
  9. onClipEvent(enterFrame){
  10.     VelX = VelX * 0.7 ;
  11.     VelY += AccY ;
  12.     PosX += VelX ;
  13.     PosY += VelY ;
  14.     if(PosY >= ground ){
  15.             VelY = Math.abs(VelY) * 0.4 ;
  16.             PosY = ground ;
  17.             if(Key.isDown(Key.SPACE)){
  18.                 VelY = -45;
  19.             }
  20.         }
  21.     if(Key.isDown(Key.LEFT)){
  22.         VelX = -15 ;
  23.     }
  24.     if(Key.isDown(Key.RIGHT)){
  25.         VelX = 15 ;
  26.     }
  27.     _root.ball_mc._x = PosX ;
  28.     _root.ball_mc._y = PosY ;
  29.     if( _parent.Floor.down = 1 ){
  30.             this.ground = 530 ;
  31.         }
  32. }


Y este código para la Planta:

Código: [ Select ]
onClipEvent(load){
    down = 1 ;
}
onClipEvent(enterFrame){
    if(_parent.ball_mc._y <= this._y &&
     _parent.ball_mc._y > (this._y - 50) &&
     ( _parent.ball_mc._x + 10 ) > this._x &&
        _parent.ball_mc._x < ( this._x + this._width) ){
        _parent.ball_mc.ground = this._y ;
        down = 0 ;
    }else{
        down = 1;
    }
}
  1. onClipEvent(load){
  2.     down = 1 ;
  3. }
  4. onClipEvent(enterFrame){
  5.     if(_parent.ball_mc._y <= this._y &&
  6.      _parent.ball_mc._y > (this._y - 50) &&
  7.      ( _parent.ball_mc._x + 10 ) > this._x &&
  8.         _parent.ball_mc._x < ( this._x + this._width) ){
  9.         _parent.ball_mc.ground = this._y ;
  10.         down = 0 ;
  11.     }else{
  12.         down = 1;
  13.     }
  14. }

Publicar Información

  • Total de mensajes en este tema: 3 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 55 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC