我对加载和播放音效有点困惑.我的游戏设置在不同的状态,首先Preloader状态确保加载所有图像和声音.GameState是主要游戏,每个下一个级别重新启动此状态.有不同的级别,但状态是相同的,它只是更改一个_levelIndex变量并使用相同的状态.
GameState在.create()函数中为游戏添加所需的音频,每次启动GameState时都会调用此create-function.见下面的代码
mygame.Preloader.prototype = {
preload: function(){
this.loadingbar_bg = this.add.sprite(80, 512, "loadingbar_bg");
this.loadingbar_fill = this.add.sprite(80, 512, "loadingbar_fill");
this.load.setPreloadSprite(this.loadingbar_fill);
// load sounds
this.load.audio("button", ["snd/button.mp3", "snd/button.ogg"]);
this.load.audio("punch", ["snd/punch.mp3", "snd/punch.ogg"]);
this.load.audio("coin", ["snd/coin.mp3", "snd/coin.ogg"]);
},
create: function() {
this.state.start("MainGame");
},
};
mygame.GameState.prototype = {
create: function() {
this.stage.backgroundColor = "#f0f";
// etc.
// sound effects
this.sound1 = this.game.add.audio("button");
this.sound2 = this.game.add.audio("punch");
this.sound3 = this.game.add.audio("coin");
//etc.
},
update: function() {
if (hitFace) {
this.sound2.play();
hitFace = false;
};
},
doNextLevel: function() …Run Code Online (Sandbox Code Playgroud) 前段时间我使用Eclipse和Phonegap,我已成功部署了一些Android应用程序.所以现在我正试图在Android Studio中启动并运行新的Phonegap/Cordova应用程序,但到目前为止没有任何运气.这是我尝试过的:
1)我已经生成了一个cordova应用程序并添加了android作为平台.
cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add android
cordova -version
Run Code Online (Sandbox Code Playgroud)
好的,这很有效
2)然后我启动Android Studio并导入生成的应用程序,并显示消息"此项目的Gradle设置尚未配置",然后按OK.

3)然后我得到一个错误"摇篮1.10版是必需的.目前的版本是2.2.1"和一些谷歌上搜索后,我发现一个提示这里,我在摇篮改线从'com.android.tools.build:gradle:0.10.+'到:0.14.+'现在顶部的运行图标被启用,因此它似乎已经修复了至少一些东西.虽然版本nr对我没有意义,但从我可以收集的内容来看,这些版本非常具体.
但现在我坚持错误"模块android没有gradle支持",我不知道该怎么做.

任何帮助将不胜感激.
在 C# 中,如何对大数列表进行排序,使得带有-减号字符的负数也按正确的顺序排列?
我知道一个int可以容纳最多的数字。10位数字,ulong可容纳约20位数字。但我有一个24~30位数字的列表,其中包括负数。
我认为执行此操作的方法是添加一个用0' 填充的字符串,然后对该新字符串进行排序。于是就1234变成了0001234。对于负数-567则变为,9999432因为它是逆序排序的。请参阅下面的代码
private void TestingList()
{
// test values
List<string> Values123 = new List<string> {
"123456789012345678901234",
"-61309282998165063700291",
"72413799900717492396359",
"-10076416403816370211636",
"123191989931658420157210",
"-675299502697548089298418",
"554706403711546488433874",
"-882666356021157245451325",
"877873677336436172875781",
"-695217734376922329970499"
};
//List<string> Values123 = new List<string> {"2222", "4444", "3333", "1111", "5555"};
// create a sortable list, of type List<String, String>
var Test123 = new List<KeyValuePair<string, string>>();
foreach (var v in Values123)
{
Test123.Add(new KeyValuePair<string, string>(sortableValue(v), …Run Code Online (Sandbox Code Playgroud)