不同场景,AS3 中不同帧率

问题描述 投票:0回答:1

如何使此代码在 3 个不同场景的不同帧速率下正确?有例子吗?

源自 Actionscript 3.0 - 更改场景的 FPS 不起作用

function modifyFrameRate():void {
    stage.frameRate = this.currentScene.name == 'Scene 1' ? 2 : 40;
}
modifyFrameRate();

我的代码:

function modifyFrameRate():void {
    stage.frameRate = this.currentScene.name == 'Title' ? 'Game' : 60;
    stage.frameRate = this.currentScene.name == 'Intro Scene' ? 'Game' : 60;
    stage.frameRate = this.currentScene.name == 'Game' ? 'Ending Scene' : 24;
}
modifyFrameRate();
actionscript-3 frame-rate scene
1个回答
0
投票

原始代码在两种模式之间进行选择,这就是使用三元运算符的原因。如果您有更多场景,则创建一个 key:value 字典更有意义,其中场景名称是键,帧速率是值:

var SceneToRate:Object =
{
    'Title': 10,
    'Intro Scene': 120,
    'Game': 60,
    'Ending Scene': 24
}

function updateFrameRate():void
{
    stage.frameRate = SceneToRate[currentScene.name];
}
© www.soinside.com 2019 - 2024. All rights reserved.