别踩白块开在unity里如何实现计分
答案:2 悬赏:20 手机版
解决时间 2021-01-18 03:23
- 提问者网友:感性作祟
- 2021-01-17 06:09
别踩白块开在unity里如何实现计分
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-01-17 07:14
找到了这个,具体的也不知道能不能帮助到你
#创建分数结束节点this.createTopOverNode();
#改变分数节点的颜色背景,结果失败;
[mw_shl_code=java,true]
6 创建添加新的一行
[mw_shl_code=java,true]MainLayer.prototype.moveAddNewSprites = function () {
cc.log("moveAddNewSprites");
var sprites = new Array(4);
var random = getRandom(4);
for (var k = 0; k < 4; k++) {
sprites[k] = this.newBlock(k, this.pianoLength, random);
}
this.tables[this.pianoLength] = sprites;
this.pianoLength += 1;
};[/mw_shl_code]
7 分数结束节点创建函数
[mw_shl_code=java,true]MainLayer.prototype.createTopOverNode = function () {
//top score node
this.scoreNode = cc.Node.create();
this.scoreNode.setPosition(cc.p(0, this.blockHeight * this.pianoLength));
this.scoreNode.setAnchorPoint(cc.p(0, 0));
this.scoreNode.setZOrder(130);
this.blockNode.addChild(this.scoreNode);
//color bg
var bgColor = cc.Sprite.create("res/whiteBlock.png");
bgColor.setPosition(cc.p(0, 0));
bgColor.setScaleX(720 / 300);
bgColor.setScaleY(1280 / 500);
bgColor.setAnchorPoint(cc.p(0, 0));
bgColor.setColor(cc.c3b(0, 255, 0));
this.scoreNode.addChild(bgColor);
this.scoreNode.bgColor = bgColor;
//mode
var wordsMode = ["经典", "街机", "禅"];
var modeLabel = cc.LabelTTF.create(wordsMode[GAME_MODE] + "模式", "Arial", 70);
this.scoreNode.addChild(modeLabel);
modeLabel.setPosition(cc.p(350, 1000));
modeLabel.setColor(cc.c3b(0, 0, 0));
modeLabel.setAnchorPoint(cc.p(0.5, 0.5));
//result
var resultLabel = cc.LabelTTF.create("成功了", "Arial", 110);
this.scoreNode.addChild(resultLabel);
resultLabel.setPosition(cc.p(360, 750));
resultLabel.setAnchorPoint(cc.p(0.5, 0.5));
resultLabel.setColor(cc.c3b(139, 58, 58));
this.scoreNode.result = resultLabel;
//back
var backLabel = cc.LabelTTF.create("返回", "Arial", 50);
this.scoreNode.addChild(backLabel);
backLabel.setPosition(cc.p(200, 400));
backLabel.setAnchorPoint(cc.p(0.5, 0.5));
backLabel.setColor(cc.c3b(0, 0, 0));
this.scoreNode.back = backLabel;
//return
var returnLabel = cc.LabelTTF.create("重来", "Arial", 50);
this.scoreNode.addChild(returnLabel);
returnLabel.setPosition(cc.p(500, 400));
returnLabel.setAnchorPoint(cc.p(0.5, 0.5));
returnLabel.setColor(cc.c3b(0, 0, 0));
this.scoreNode.return = returnLabel;
};[/mw_shl_code]
6969g手游论坛为您解答
#创建分数结束节点this.createTopOverNode();
#改变分数节点的颜色背景,结果失败;
[mw_shl_code=java,true]
this.createTopOverNode(); //create score node and move[/mw_shl_code]
this.gameStatus = OVER;
cc.AudioEngine.getInstance().playEffect(SOUNDS.error, false);
block.setColor(cc.c3b(255, 0, 0));
block.runAction(cc.Sequence.create(
cc.ScaleTo.create(0, this.scaleX * 4 / 5, this.scaleY * 4 / 5),
cc.ScaleTo.create(0.2, this.scaleX, this.scaleY)
));
this.scoreNode.bgColor.setColor(cc.c3b(255, 0, 0));
this.scoreNode.result.setString("失败了");
this.scoreNode.runAction(cc.MoveTo.create(0.2, cc.p(0, this.blockHeight * this.moveNum)));
6 创建添加新的一行
[mw_shl_code=java,true]MainLayer.prototype.moveAddNewSprites = function () {
cc.log("moveAddNewSprites");
var sprites = new Array(4);
var random = getRandom(4);
for (var k = 0; k < 4; k++) {
sprites[k] = this.newBlock(k, this.pianoLength, random);
}
this.tables[this.pianoLength] = sprites;
this.pianoLength += 1;
};[/mw_shl_code]
7 分数结束节点创建函数
[mw_shl_code=java,true]MainLayer.prototype.createTopOverNode = function () {
//top score node
this.scoreNode = cc.Node.create();
this.scoreNode.setPosition(cc.p(0, this.blockHeight * this.pianoLength));
this.scoreNode.setAnchorPoint(cc.p(0, 0));
this.scoreNode.setZOrder(130);
this.blockNode.addChild(this.scoreNode);
//color bg
var bgColor = cc.Sprite.create("res/whiteBlock.png");
bgColor.setPosition(cc.p(0, 0));
bgColor.setScaleX(720 / 300);
bgColor.setScaleY(1280 / 500);
bgColor.setAnchorPoint(cc.p(0, 0));
bgColor.setColor(cc.c3b(0, 255, 0));
this.scoreNode.addChild(bgColor);
this.scoreNode.bgColor = bgColor;
//mode
var wordsMode = ["经典", "街机", "禅"];
var modeLabel = cc.LabelTTF.create(wordsMode[GAME_MODE] + "模式", "Arial", 70);
this.scoreNode.addChild(modeLabel);
modeLabel.setPosition(cc.p(350, 1000));
modeLabel.setColor(cc.c3b(0, 0, 0));
modeLabel.setAnchorPoint(cc.p(0.5, 0.5));
//result
var resultLabel = cc.LabelTTF.create("成功了", "Arial", 110);
this.scoreNode.addChild(resultLabel);
resultLabel.setPosition(cc.p(360, 750));
resultLabel.setAnchorPoint(cc.p(0.5, 0.5));
resultLabel.setColor(cc.c3b(139, 58, 58));
this.scoreNode.result = resultLabel;
//back
var backLabel = cc.LabelTTF.create("返回", "Arial", 50);
this.scoreNode.addChild(backLabel);
backLabel.setPosition(cc.p(200, 400));
backLabel.setAnchorPoint(cc.p(0.5, 0.5));
backLabel.setColor(cc.c3b(0, 0, 0));
this.scoreNode.back = backLabel;
//return
var returnLabel = cc.LabelTTF.create("重来", "Arial", 50);
this.scoreNode.addChild(returnLabel);
returnLabel.setPosition(cc.p(500, 400));
returnLabel.setAnchorPoint(cc.p(0.5, 0.5));
returnLabel.setColor(cc.c3b(0, 0, 0));
this.scoreNode.return = returnLabel;
};[/mw_shl_code]
6969g手游论坛为您解答
全部回答
- 1楼网友:往事隔山水
- 2021-01-17 07:22
添加碰撞器,根据Tag区分碰撞类型
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯