ActionScript 3.0 - 跨两个动画片段的变量共享。复杂

时间:2015-01-05 20:29:22

标签: actionscript-3 flash actionscript action

我有一个非常有趣的问题,与我的手机游戏开发中的主角动画有关。

我有一个电影剪辑,我的玩家arm / attackArm,附在他身体的移动动画上[在HERO的第1帧]

我还有另一个arm / attackArm的动画片段,附在他的跳跃和下降的动画片上[在HERO的第2 + 3帧]

我需要通过THROWframe / CurrentThrowFrame的变量或变量在两者之间进行交叉通信。能够修复某个错误。

错误在于,当我投掷长矛和跳跃(中间投掷动画)时,他继续在投掷动画中离开的地方。无论其,,,

当我跳跃时,然后抛出[无论他是否在第2帧或第3帧,下降或向上行进,因为两者共享相同的ARM] ;;;在击中地面时,他的投掷动画重置回到第0帧,无论他是否在空中投掷。

有人可以帮忙吗?我知道,这是非常具体的。 欢迎任何和所有帮助。

这是一段代码。

    // PLAYER : SHOOT (OVERALL)
    public function playerShoot(m:MouseEvent):void
    {

        //Running Shoot
        ///////////////
        if (JungleBob.player.currentFrame == 1 && JungleBob.player.runBody.runBody2.playerWeaponArm.currentFrame == 1)

        {
        var angle_in_radF1:Number = Math.atan2(mouseY - (JungleBob.player.y + JungleBob.player.runBody.runBody2.playerWeaponArm.y - (36)), mouseX - (JungleBob.player.x + JungleBob.player.runBody.runBody2.playerWeaponArm.x + (32)));
        var heroBullet_mcF1:MovieClip = new projectile_spear();
        Heros_Bullets_Array.push(heroBullet_mcF1);


        heroBullet_mcF1.x = (JungleBob.player.x + (JungleBob.player.runBody.runBody2.playerWeaponArm.x) + (32));
        heroBullet_mcF1.y = (JungleBob.player.y + (JungleBob.player.runBody.runBody2.playerWeaponArm.y) - (36));

        heroBullet_mcF1.rotation = angle_in_radF1 * 180/Math.PI;
        JungleBob.player.runBody.runBody2.playerWeaponArm.rotation = angle_in_radF1 * 180/Math.PI + (10);

        addChild(heroBullet_mcF1);
        JungleBob.mainClass.randomThrowSoundTraffic();

        JungleBob.player.runBody.runBody2.playerWeaponArm.gotoAndPlay(2);

        (new Tween(JungleBob.Vcamera,'x',Strong.easeOut,630,625,0.5,true));

        }

        //Jumping and Falling Shoot
        ///////////////////////////
        if (JungleBob.player.currentFrame >= 2 && JungleBob.player.playerWeaponArm.currentFrame == 1)

        {
        var angle_in_rad:Number = Math.atan2(mouseY - (JungleBob.player.y + JungleBob.player.playerWeaponArm.y - (36)), mouseX - (JungleBob.player.x + JungleBob.player.playerWeaponArm.x + (32)));
        var heroBullet_mc:MovieClip = new projectile_spear();
        Heros_Bullets_Array.push(heroBullet_mc);

        heroBullet_mc.x = (JungleBob.player.x + (JungleBob.player.playerWeaponArm.x) + (32));
        heroBullet_mc.y = (JungleBob.player.y + (JungleBob.player.playerWeaponArm.y) - (36));

        heroBullet_mc.rotation = angle_in_rad * 180/Math.PI;
        JungleBob.player.playerWeaponArm.rotation = angle_in_rad * 180/Math.PI + (10);
        addChild(heroBullet_mc);
        JungleBob.mainClass.randomThrowSoundTraffic();


        JungleBob.player.playerWeaponArm.gotoAndPlay(2);

        (new Tween(JungleBob.Vcamera,'x',Strong.easeOut,630,625,0.5,true));


        }

    }


            // PLAYER : SHOOT (LISTENERS)
            //


            //Other Throw Frame Listener
            public function otherListener(e:Event):void 
            {
                if ((hero_mc.canJump == true) &&  ThrowFrame == 0)
                {
                    stage.addEventListener(Event.ENTER_FRAME, throwFrameListener);
                }
            }

            //Throw Frame Listener
            public function throwFrameListener (e:Event):void
            {
                if (JungleBob.player.currentFrame == 1)
                {
                    ThrowFrame = JungleBob.player.runBody.runBody2.playerWeaponArm.currentFrame;
                }

                if ( (JungleBob.player.currentFrame >= 2) && (ThrowFrame >= 2) && (hero_mc.yVelocity <= 0) )
                {
                    JungleBob.player.playerWeaponArm.gotoAndPlay(ThrowFrame);
                    stage.removeEventListener(Event.ENTER_FRAME, throwFrameListener);
                }

            }

最好的运气 &安培;&安培; 感谢提前

0 个答案:

没有答案