var ps = require('PS');
cc.Class({
extends: cc.Component,
properties: {
ui: cc.Node,
hero: cc.Node, // 主角
pre_pillar: cc.Prefab, // 柱子预制
pillar_container: cc.Node, // 柱子容器
ship: cc.Node, // 船
rope1: cc.Node, // 绳子
rope2: cc.Node,
logo: cc.Node, // logo
btn_start: cc.Node, // 开始游戏按钮
speed: 100, // 柱子下移速度
panel_renew: cc.Node, // 复活面板
lbl_score: cc.Label, // 得分
lbl_coin: cc.Label, // 金币
panel_gameOver: cc.Node, // 游戏结束面板
lbl_gameOverScore: cc.Label, // 游戏结束面板得分
lbl_gameOverCoin: cc.Label, // 游戏结束面板金币
label_best_score: cc.Label, // 游戏结束面板最高分
guide: cc.Node, // 游戏引导
audio_node: cc.Node, // 音效
panel_setting: cc.Node, // 设置面板
btn_music_on: cc.Node,
btn_music_off: cc.Node,
btn_effect_on: cc.Node,
btn_effect_off: cc.Node,
panel_rank: cc.Node, // 排行榜面板
shareImgs: [cc.Texture2D], // 分享图片
pre_alert: cc.Prefab, // 弹窗
particle_bone: cc.Prefab, // 骨头粒子
// decorationNode: cc.Node, // 装饰节点
particle_click: cc.Prefab, // 点击粒子预制
btn_pause: cc.Node, // 暂停按钮
panel_pause: cc.Node, // 暂停面板
panel_get_drumstick: cc.Node, // 获得鸡腿面板
panel_money: cc.Node, // 领现金面板
panel_box: cc.Node, // 宝箱面板
icon_item: cc.Node, // 道具图标
spr_speed: cc.SpriteFrame, // 加速道具图标
spr_magnet: cc.SpriteFrame, // 磁铁道具图标
item_description: cc.Label, // 道具描述
btn_drumstick_renew: cc.Node, // 鸡腿复活按钮
// lbl_drumstick_num: cc.Label, // 鸡腿复活数量
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
cc.view.setDesignResolutionSize(750, 1334, cc.ResolutionPolicy.EXACT_FIT);
cc.director.getCollisionManager().enabled = true;
// 开启右上角分享
if(window.wx){
window.wx.showShareMenu();
var idx = Math.floor(Math.random() * 4);
var that = this;
window.wx.onShareAppMessage(function () {
return {
title: '这个游戏福利超级好!!!有鸡腿吃还能领钱!!!',
imageUrl:that.shareImgs[idx]
}
})
wx.updateShareMenu({
withShareTicket: true
})
// 云开发初始化
wx.cloud.init({
env: 'climb1-release'
})
};
ps.createBannerAd();
ps.createVideoAd();
ps.createGameClub();
},
start() {
this.audio = this.audio_node.getComponent('audio'); // 音乐
this.audio.playBgm();
this.isMoving = false; // 柱子是否下移
this.createPillar();
// 注册点击事件
this.node.on('touchstart', function (e) {
// 点击粒子特效
var particle = cc.instantiate(this.particle_click);
var pos = this.node.convertToNodeSpaceAR(e.getLocation());
particle.setPosition(pos);
this.node.addChild(particle);
if (pos.x < 0) {
// 点击左边屏幕
this.heroMoveLeft();
} else {
// 点击右边屏幕
this.heroMoveRight();
}
}.bind(this));
this.initData();
this.setAnim();
this.initPanelSetting();
},
// 初始化数据
initData(){
this.oldScore = cc.sys.localStorage.getItem("climb1-score");
if(this.oldScore){
this.lbl_score.string = "最高:" + this.oldScore + '米';
}else{
this.oldScore = 0;
this.lbl_score.string = '最高:0米';
}
this.oldCoin = cc.sys.localStorage.getItem("climb1-coin") - 0;
if(this.oldCoin){
this.lbl_coin.string = this.oldCoin;
}else{
this.oldCoin = 0;
this.lbl_coin.string = '0';
}
},
// 设置船和柱子的动画
setAnim(){
// 船动画
var shipAction = cc.sequence(cc.moveBy(2,0,30),cc.moveBy(2,0,-30)).repeatForever();
this.ship.runAction(shipAction);
this.pillar_container.runAction(shipAction.clone());
// 绳子动画
this.rope1.runAction(shipAction.clone());
this.rope2.runAction(shipAction.clone());
// logo动画
var logoAction = cc.repeatForever(cc.sequence(cc.scaleTo(5,1.1,1.1),cc.scaleTo(5,1,1)));
this.logo.runAction(logoAction);
// 开始按钮动画
// var btnAction = cc.repeatForever(cc.sequence(cc.scaleTo(1,1.05,1.05),cc.scaleTo(1,1,1)));
var btnAction = cc.repeatForever(cc.sequence(cc.jumpBy(1,0,0,10,3),cc.delayTime(4)));
this.btn_start.runAction(btnAction);
},
// 停止船和柱子的动画
stopAnim(){
this.ship.stopAllActions();
this.ship.setPosition(0,-491);
this.pillar_container.stopAllActions();
this.pillar_container.setPosition(0,0);
},
// 打开设置面板
openSetting(){
ps.hideGameClub();
this.audio.playEffect('click');
this.panel_setting.active = true;
},
// 关闭设置面板
closeSetting(){
ps.showGameClub();
this.audio.playEffect('click');
this.panel_setting.active = false;
},
//初始化设置面板
initPanelSetting(){
this.btn_music_on.active = !ps.isMusicOn;
this.btn_music_off.active = ps.isMusicOn;
this.btn_effect_on.active = !ps.isEffectOn;
this.btn_effect_off.active = ps.isEffectOn;
},
// 开启音乐
openMusic(){
this.audio.playEffect('click');
this.btn_music_on.active = false;
this.btn_music_off.active = true;
ps.isMusicOn = true;
this.audio.playBgm();
},
// 关闭音乐
closeMusic(){
this.audio.playEffect('click');
this.btn_music_on.active = true;
this.btn_music_off.active = false;
ps.isMusicOn = false;
this.audio.stopAll();
},
// 开启音效
openEffect(){
this.audio.playEffect('click');
this.btn_effect_on.active = false;
this.btn_effect_off.active = true;
ps.isEffectOn = true;
},
// 关闭音效
closeEffect(){
this.audio.playEffect('click');
this.btn_effect_on.active = true;
this.btn_effect_off.active = false;
ps.isEffectOn = false;
},
// 开始游戏
startGame() {
ps.hideGameClub();
this.stopAnim();
this.audio.playEffect('click');
this.ui.active = false;
this.btn_pause.active = true;
this.guide.active = true;
this.scheduleOnce(function(){
this.guide.active = false;
}.bind(this),4);
this.initGame();
},
// 初始化游戏
initGame(){
this.renewTimes = 0;
this.isMoving = true;
this.score = 0;
this.coin = 0;
this.hero.y = -667;
this.speed = 250;
this.schedule(this.heroMoveLeft, 0.11, 2);
ps.showBannerAd();
},
// 暂停游戏
pauseGame(){
this.getComponent('rank').removeRank();
ps.hideBannerAd();
this.scheduleOnce(function(){
ps.showBannerAd();
this.panel_pause.active = true;
cc.director.pause();
},0.2)
},
// 继续游戏
resumeGame(){
ps.hideBannerAd();
this.scheduleOnce(function(){
ps.showBannerAd();
},0.5)
cc.director.resume();
this.panel_pause.active
没有合适的资源?快使用搜索试试~ 我知道了~
海盗逃命.zip源码cocos creator项目源码下载
共243个文件
meta:121个
png:71个
anim:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 64 浏览量
2022-03-17
23:22:53
上传
评论
收藏 2.34MB ZIP 举报
温馨提示
海盗逃命.zip源码cocos creator项目源码下载海盗逃命.zip源码cocos creator项目源码下载 1.适合个人学习技术做项目参考 2.开发脚本为javsScropt或者typeScript 3.适合小公司开发游戏项目参考
资源推荐
资源详情
资源评论
收起资源包目录
海盗逃命.zip源码cocos creator项目源码下载 (243个子文件)
guide.anim 2KB
water.anim 1KB
hero.anim 772B
bird.anim 769B
circle.anim 554B
more-game.anim 520B
cloud3.anim 470B
cloud1.anim 470B
cloud2.anim 469B
text.anim 465B
helm.anim 378B
light.anim 377B
flag.anim 377B
.DS_Store 10KB
.DS_Store 6KB
game.fire 269KB
font-fangmeng.fnt 13KB
shareImg.jpg 73KB
shareImg6.jpg 12KB
shareImg4.jpg 10KB
shareImg5.jpg 8KB
game.js 22KB
PS.js 6KB
rank.js 3KB
audio.js 2KB
hero.js 2KB
item.js 2KB
barrier.js 1KB
pillar.js 915B
alert.js 796B
services.json 12KB
project.json 1KB
builder.json 986B
jsconfig.json 266B
project.json 60B
btn-green.png.meta 721B
btn-bg.png.meta 718B
panel-decoration.png.meta 718B
panel2.png.meta 718B
btn-circle.png.meta 717B
btn-setting.png.meta 717B
btn-friend.png.meta 717B
font-fangmeng.png.meta 717B
btn-start.png.meta 716B
ico_hand_press.png.meta 716B
btn-rank.png.meta 716B
btn-random.png.meta 716B
panel1.png.meta 716B
water1.png.meta 715B
btn-video-get.png.meta 715B
water2.png.meta 715B
panel_pop.png.meta 715B
guide_hand.png.meta 714B
panel-brown.png.meta 713B
item-speed.png.meta 713B
panel-white.png.meta 713B
panel-helm.png.meta 712B
hand-right.png.meta 712B
hero2.png.meta 712B
btn-close-gray.png.meta 712B
btn-back.png.meta 712B
guide_word.png.meta 712B
hand-left.png.meta 711B
shareImg6.jpg.meta 711B
btn-money.png.meta 711B
more-game.png.meta 711B
shareImg4.jpg.meta 711B
drumstick.png.meta 711B
shareImg5.jpg.meta 711B
btn-pause.png.meta 711B
light.png.meta 711B
item-1.png.meta 710B
whell.png.meta 710B
shareImg.jpg.meta 710B
barrier-1.png.meta 709B
barrier-3.png.meta 709B
barrier-4.png.meta 709B
panel-cross.png.meta 709B
hero1.png.meta 709B
item-2.png.meta 709B
barrier-2.png.meta 709B
panel-top.png.meta 709B
pillar.png.meta 708B
cloud1.png.meta 708B
icon-video.png.meta 708B
cloud2.png.meta 708B
cloud3.png.meta 708B
circle.png.meta 708B
star.png.meta 708B
smoke.png.meta 707B
coin.png.meta 707B
btn-video.png.meta 707B
rope2.png.meta 707B
logo2.png.meta 707B
bird3.png.meta 707B
bird1.png.meta 707B
rope1.png.meta 707B
palel.png.meta 707B
btn-close.png.meta 707B
shark.png.meta 707B
共 243 条
- 1
- 2
- 3
资源评论
- 我爱科比嗯2022-12-02资源内容详细,总结地很全面,与描述的内容一致,对我启发很大,学习了。
yxkfw
- 粉丝: 76
- 资源: 2万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功