dimanche 25 décembre 2022

randomize Nested symbols for coin blocks

I am back for a long due break. I want to know how to randomize the frames for coin blocks.

Code:

if(coinblock1.hitTestObject(blowfishPong) == true){
            if (ballSpeedXCoinGame > 0) {
                ballSpeedXCoinGame *= -1;
                ballSpeedYCoinGame = calculateBallAngleCoinGame((character.y, blowfishPong.y);
                var randomCoin = Math.floor(Math.random() * coinblock.length+1);
                gotoAndStop(randomCoin);
                if(randomCoin.currentFrame == 2){
                    coin += 1;
                    CoinSFX.play();
                }
                else if(randomCoin.currentFrame == 12){
                    coin += 5;
                    CoinSFX.play();
                }
                else if(randomCoin.currentFrame == 22){
                    coin += 10;
                    CoinSFX.play();
                }
                else if(randomCoin.currentFrame == 32){
                    coin += 50;
                    CoinSFX.play();
                }
                else if(randomCoin.currentFrame == 42){
                    coin += 100;
                    CoinSFX.play();
                }
        }
    }

ArgumentError:

Error #2109: Frame label NaN not found in scene Main Game.
    at flash.display::MovieClip/gotoAndStop()
    at BlowfishPong_CoinGameTest__fla::MainTimeline/loopCoinGame()[BlowfishPong_CoinGameTest__fla.MainTimeline::frame1:131]

How to randomize the range for following frames rather than the beginning for the coin block?




Aucun commentaire:

Enregistrer un commentaire