// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
highestScore:0,
bluePrefab1:{
default:null,
type:cc.Prefab
},
redPrefab1:{
default:null,
type:cc.Prefab
},
greenPrefab1:{
default:null,
type:cc.Prefab
},
orangePrefab1:{
default:null,
type:cc.Prefab
},
purplePrefab1:{
default:null,
type:cc.Prefab
},
//存放泡泡的颜色种类,元素是colorPrefab1
bubbleType:{
default:null,
type:Array
},
//存放泡泡的颜色种类,元素是string
bubbleType:{
default:null,
type:String
},
//存放当前应该点击的泡泡颜色
bubblePoint:{
default:null,
type:Array
},
//中线位置
middleLine:0,
//圆圈的半径
radius:30,
//半边屏幕中放得下半个圆圈的行数
rows:10,
//是否重新生成圆圈的标志
redraw:0,
//点击到的泡泡的颜色
color:"none",
//应该点击到的泡泡的颜色
rightColor:"none",
//记录分数的label
scoreLabel:{
default:null,
type:cc.Label
},
//记录最高分的label
highestScoreLabel:{
default:null,
type:cc.Label
},
//分数
score:0,
//生命值
heart:0,
//提示词的label
hintLabel:{
default:null,
type:cc.Label,
},
//所有颜色的
allColors:{
default:null,
type:Array
},
//游戏结束的提示字
gameover:{
default:null,
type:cc.Node,
},
//返回标题的按钮
backmain:{
default:null,
type:cc.Node,
},
//重新开始的按钮
restart:{
default:null,
type:cc.Node,
},
//所有生命值的图案
allHeart:{
default:null,
type:Array,
},
//销毁生命值的下标
heartIndex:0,
//空生命值
emptyHeart:{
default:null,
type:cc.SpriteFrame,
},
//新纪录提示符
newRecord:{
default:null,
type:cc.Node,
},
},
// LIFE-CYCLE CALLBACKS:
onLoad: function() {
//确定中线位置
this.middleLine=Math.floor(this.node.height/2);
this.radius=Math.floor(this.middleLine/this.rows);
//记录bubble类型的数组
this.bubbleType=new Array();
this.bubbleType[0]=this.bluePrefab1;
this.bubbleType[1]=this.redPrefab1;
this.bubbleType[2]=this.greenPrefab1;
this.bubbleType[3]=this.orangePrefab1;
this.bubbleType[4]=this.purplePrefab1;
//记录bubble颜色的数组
this.bubbleTypeName=new Array();
this.bubbleTypeName[0]="蓝";
this.bubbleTypeName[1]="红";
this.bubbleTypeName[2]="绿";
this.bubbleTypeName[3]="橙";
this.bubbleTypeName[4]="紫";
//所有颜色的rgba值
this.allColors=new Array();
this.allColors[0]=new cc.color(79,135,219,177);//蓝色
this.allColors[1]=new cc.color(182,50,50,168);//红色
this.allColors[2]=new cc.color(102,170,132,197);//绿色
this.allColors[3]=new cc.color(231,107,10,232);//橙色
this.allColors[4]=new cc.color(194,17,228,168);//紫色
//初始化应当点击的颜色
var index=Math.floor(Math.random()*this.bubbleTypeName.length);
this.rightColor=this.bubbleTypeName[index];
//初始化分数
this.score=0;
this.scoreLabel.string="SCORE:"+String(this.score);
cc.find("Canvas/score").setPosition(Math.floor(-this.node.width/2+this.radius/5),-this.node.height/2+this.radius*1.5);
cc.find("Canvas/score").setContentSize(Math.floor(this.node.height/2),this.radius/4);
console.log(Math.floor(this.node.width/4),Math.floor(this.node.width/20));
//初始化最高分
this.highestScore=parseInt(cc.sys.localStorage.getItem("score"));
if(Number.isNaN(this.highestScore))
{
this.highestScore=0;
}
this.highestScoreLabel.string="BEST:"+String(this.highestScore);
cc.find("Canvas/highestScore").setPosition(Math.floor(-this.node.width/2+this.radius*6/5),-this.node.height/2+this.radius*1.5);
cc.find("Canvas/highestScore").setContentSize(Math.floor(this.node.height/2),this.radius/4);
//初始化提示词
this.hintLabel.string=this.rightColor;
cc.find("Canvas/hint").color=this.allColors[(index+Math.floor(Math.random()*100))%this.bubbleTypeName.length];
cc.find("Canvas/hint").setContentSize(Math.floor(this.node.width/4),Math.floor(this.radius*4/3));
cc.find("Canvas/hint").setPosition(Math.floor(-this.node.width/2+this.radius/3),this.radius*1.5);
console.log(Math.floor(this.node.width/4),Math.floor(this.node.width/20));
//初始化小熊
console.log(cc.find("Canvas/teddy"));
cc.find("Canvas/teddy").setContentSize(this.radius*2,this.radius*2.7);
cc.find("Canvas/teddy").setPosition(-this.node.width/2+Math.floor(this.radius/2),0);
//console.log(cc.find("Canvas/teddy"));
//初始化分割线的位置和宽度
cc.find("Canvas/baseline").setContentSize(this.node.height*1.5,this.radius/3);
cc.find("Canvas/baseline").setPosition(-this.node.width/2+this.radius*2,5);
//把游戏结束的按钮和提示词藏起来
this.gameover.setContentSize(this.node.height,this.radius*2.5);
this.backmain.setContentSize(this.radius*3,this.radius*1.3);
this.restart.setContentSize(this.radius*3,this.radius*1.3);
this.newRecord.setContentSize(this.radius*2.4,this.radius*1.3);
this.gameover.setPosition(this.node.width,0);
this.backmain.setPosition(this.node.width+this.radius*4,this.radius);
this.restart.setPosition(this.node.width+this.radius*4,-this.radius);
this.newRecord.setPosition(this.node.width+this.radius*4,-this.radius);
//初始化生命值
this.allHeart=new Array(3);
this.allHeart[0]=cc.find("Canvas/heart1");
this.allHeart[1]=cc.find("Canvas/heart2");
this.allHeart[2]=cc.find("Canvas/heart3");
var i=0;
for(i=0;i<3;i++)
{
this.allHeart[i].setContentSize(this.radius,this.radius);
this.allHeart[i].setPosition(Math.floor(-this.node.width/2+this.radius/3),this.node.height/2-this.radius*(i*1.5+1));
}
console.log("生命值:");
console.log(this.allHeart[0]);
this.drawBubble()
},
drawBubble:function(){
this.spawnNewBubble(0,this.middleLine);
this.spawnNewBubble(-this.middleLine,0);
},
spawnNewBubble:function(ymin,ymax){
//将半边屏幕划分为刚好放得下1/4个圆圈的几个区域
var cols=Math.floor(this.node.width/this.radius);
//var rows=Math.floor(this.middleLine/this.radius);
var bubblePositions=new Array();
var i=0;
var j=0;
var count=0;
var index=0;
for(i=0;i<this.rows;i++){
bubblePositions[i]=new Array();
for(j=0;j<cols;j++){
//记录每个小�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
泡泡点击.zip源码cocos creator项目源码下载泡泡点击.zip源码cocos creator项目源码下载 1.上线产品适合个人学习技术做项目参考 2.开发脚本为javsScropt或者typeScript 3.上线产品适合小公司开发游戏项目参考
资源推荐
资源详情
资源评论
收起资源包目录
泡泡点击.zip源码cocos creator项目源码下载 (125个子文件)
maingame.fire 39KB
game.fire 20KB
instruction.fire 14KB
SCORE.fnt 2KB
颜色文字.fnt 686B
Game.js 14KB
Bubble.js 2KB
Teddy.js 1KB
MainMenu.js 1KB
MainBackground.js 1KB
StartButton.js 1KB
Instruction.js 1KB
baseline.js 1KB
Heart.js 977B
Hint.js 971B
InstructionButton.js 533B
backmain.js 215B
builder.json 1KB
project.json 723B
jsconfig.json 266B
builder.panel.json 177B
wechatgame.json 175B
bmfont-ttf.json 172B
project.json 169B
services.json 63B
backMainMenuButtonDown.png.meta 830B
instructionButtonDown.png.meta 829B
restartButtonDown.png.meta 825B
button-background.png.meta 824B
startButtonDown.png.meta 823B
backMainMenuButton.png.meta 822B
instructionButton.png.meta 821B
颜色文字.png.meta 819B
玩法说明.png.meta 817B
bubble-purple.png.meta 817B
bubble-orange.png.meta 817B
restartButton.png.meta 817B
没有爱心.png.meta 817B
标题1.png.meta 816B
bubble-green.png.meta 816B
backgroud-2.png.meta 815B
bubble-blue.png.meta 815B
startButton.png.meta 815B
bubble-red.png.meta 814B
HelloWorld.png.meta 814B
backgroud2.png.meta 814B
新纪录.png.meta 813B
backgroud.png.meta 813B
teddy2.png.meta 812B
teddy1.png.meta 812B
SCORE.png.meta 811B
分割线.png.meta 810B
爱心.png.meta 810B
singleColor.png.meta 803B
Script.meta 250B
Texture.meta 250B
audio.meta 250B
Scene.meta 250B
baseline.js.meta 197B
Game.js.meta 197B
Hint.js.meta 197B
Teddy.js.meta 197B
StartButton.js.meta 197B
Heart.js.meta 197B
backmain.js.meta 197B
Instruction.js.meta 197B
MainBackground.js.meta 197B
Bubble.js.meta 197B
MainMenu.js.meta 197B
InstructionButton.js.meta 197B
bubble-purple.prefab.meta 169B
backmain.prefab.meta 169B
bubble-green.prefab.meta 169B
bubble-orange.prefab.meta 169B
bubble-red.prefab.meta 169B
bubble-blue.prefab.meta 169B
restart.prefab.meta 169B
SCORE.fnt.meta 164B
颜色文字.fnt.meta 164B
game.fire.meta 146B
instruction.fire.meta 146B
maingame.fire.meta 146B
jump.mp3.meta 133B
jump-[AudioTrimmer.com].mp3.meta 133B
score.mp3.meta 133B
score.mp3 8KB
jump-[AudioTrimmer.com].mp3 7KB
jump.mp3 6KB
bubble-orange.png 173KB
bubble-purple.png 167KB
bubble-red.png 150KB
bubble-green.png 146KB
bubble-blue.png 140KB
SCORE.png 139KB
玩法说明.png 45KB
HelloWorld.png 37KB
颜色文字.png 33KB
teddy2.png 28KB
teddy1.png 28KB
标题1.png 21KB
共 125 条
- 1
- 2
资源评论
yxkfw
- 粉丝: 77
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功