var initObj=require('initObj');
var player=initObj.player;
cc.Class({
extends: cc.Component,
properties: {
gameNode:{
default:null,
type:cc.Node
},
ropeNode:{
default:null,
type:cc.Node
},
clawNode:{
default:null,
type:cc.Node
},
claw0Node:{
default:null,
type:cc.Node
},
claw1Node:{
default:null,
type:cc.Node
}
},
onLoad:function(){
this.animation=this.node.getComponent(cc.Animation);
this.game=this.gameNode.getComponent('game');
this.rope=this.ropeNode.getComponent('rope');
this.claw=this.clawNode.getComponent('claw');
this.claw0=this.claw0Node.getComponent('claw0');
this.claw1=this.claw1Node.getComponent('claw1');
},
init: function () {
this.texture=this.getComponent(cc.Sprite).spriteFrame;
this.minerToRight();
},
minerToRight:function(){
var delay=1;
var minerAction =cc.moveTo(delay, cc.p(0, initObj.miner.position.y));
this.node.setPosition(initObj.miner.position);
this.node.runAction(minerAction);
this.animation.play('miner-appear');
this.scheduleOnce(function() {
this.animation.stop();
this.getComponent(cc.Sprite).spriteFrame=this.texture;
this.ropeRotate();
this.game.gameRun();
}, delay,this);
},
minerToleft:function(){
var finished = cc.callFunc(function(target) {
this.animation.stop();
this.game.goNext();
}, this);
var minerAction =cc.moveTo(1.5,initObj.miner.position);
this.node.runAction(cc.sequence(minerAction,finished));
},
getAnimation:function(speed){
this.animationType='miner-pull-'+speed.type;
this.animation.play(this.animationType);
this.getSpeend=speed.numb;
},
ropeRotate:function(){
var rope=this.ropeNode;
var rote=75;
var drictive=1;
var y=this.clawNode.y;
var height=this.ropeNode.height;
var hasPause=false;
var endAnimation=false;
this.state='rotate';
this.callback=function(){
if(!player.isgamerun()){
if(this.state=='rotate'){
player.preMoney=0;
this.minerToleft();
this.unschedule(this.callback);
}else{
if(!endAnimation){
this.clawOpen();
this.claw.objHide();
this.state='up';
this.animation.stop();
this.getAnimation(initObj.fastSpeed)
this.animation.play(this.animationType);
endAnimation=true;
}
up.call(this);
}
}else{
if(!player.pause){
switch(this.state)
{
case 'down':
down.call(this)
break;
case 'up':
if(hasPause){
this.animation.play(this.animationType);
hasPause=false;
}
up.call(this);
break;
default:
roate.call(this);
}
}else{
if(this.state=='up'){
this.animation.pause();
hasPause=true;
}
}
}
}
this.schedule(this.callback, 0.01);
function up(){
var speend=this.getSpeend;
this.ropeNode.height-=speend;
this.clawNode.y+=speend;
if(this.clawNode.y>=y){
this.state='rotate';
this.clawNode.y=y;
this.ropeNode.height=height;
this.animation.stop();
this.getComponent(cc.Sprite).spriteFrame=this.texture;
this.clawOpen();
this.game.minerUp();
}
}
function down(){
var speend=10;
this.ropeNode.height+=speend;
this.clawNode.y-=speend;
}
function roate(){
rope.rotation+=drictive;
if(rope.rotation>rote){
drictive=-1;
}
if(rope.rotation<-rote){
drictive=1;
}
}
},
clawOpen:function(){
var action1 = cc.rotateTo(0.2, 0);
var action2 = cc.rotateTo(0.2, 0);
this.claw0Node.runAction(action1);
this.claw1Node.runAction(action2);
},
clawClose:function(){
var action1 = cc.rotateTo(0.1, -15);
var action2 = cc.rotateTo(0.1, 15);
this.claw0Node.runAction(action1);
this.claw1Node.runAction(action2);
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
cocos creator 黄金矿工项目源码 (144个子文件)
miner-pull-heavy.anim 2KB
miner-pull-light.anim 1KB
miner-pull-fast.anim 1KB
miner-appear.anim 1KB
miner-thorw.anim 950B
miner_face.anim 773B
miner_leg.anim 772B
cave.anim 769B
obj-gold2.anim 748B
obj-gold1.anim 623B
index.fire 50KB
LeaveScene.fire 49KB
.gitignore 1KB
shop-background.jpg 125KB
level-background-0.jpg 82KB
level-background-1.jpg 47KB
menu-background-sky.jpg 31KB
miner.js 5KB
menu.js 4KB
config.js 3KB
game.js 3KB
index.js 3KB
state.js 2KB
claw.js 1KB
ButtonScaler.js 1KB
obj.js 934B
levelover.js 567B
bg.js 441B
initObj.js 358B
project.json 233B
jsconfig.json 207B
project.json 60B
level-sheet.plist.meta 71KB
general-sheet.plist.meta 46KB
miner-sheet-1.plist.meta 12KB
miner-sheet-2.plist.meta 11KB
level-background-1-mountain.png.meta 704B
menu-start-gold.png.meta 695B
menu-background-sky.jpg.meta 692B
general-sheet.png.meta 692B
miner-sheet-2.png.meta 692B
level-background-0.jpg.meta 691B
level-background-1.jpg.meta 691B
miner-sheet-1.png.meta 691B
dialog-background.png.meta 690B
menu-background.png.meta 689B
shop-background.jpg.meta 688B
level-sheet.png.meta 688B
gold-miner-text.png.meta 686B
menu-miner.png.meta 686B
shop-desk.png.meta 682B
mask-bk.png.meta 676B
index.fire.meta 146B
LeaveScene.fire.meta 146B
menu.js.meta 109B
game.js.meta 109B
levelover.js.meta 109B
state.js.meta 109B
claw.js.meta 109B
obj.js.meta 109B
miner.js.meta 109B
bg.js.meta 109B
config.js.meta 109B
initObj.js.meta 109B
index.js.meta 109B
ButtonScaler.js.meta 109B
animation.meta 108B
font.meta 108B
textures.meta 108B
script.meta 108B
data.meta 108B
game.meta 108B
UI.meta 108B
scene.meta 108B
sound.meta 108B
prefab.meta 108B
atlas.meta 108B
score2.mp3.meta 88B
pull-org.mp3.meta 88B
sound 197.mp3.meta 88B
low-value.mp3.meta 88B
cut-scene.mp3.meta 88B
menu-bg.mp3.meta 88B
normal-value.mp3.meta 88B
score1.mp3.meta 88B
level-bg.mp3.meta 88B
cut-scene-2.mp3.meta 88B
dig.mp3.meta 88B
explosive.mp3.meta 88B
high-value.mp3.meta 88B
pull.mp3.meta 88B
miner_leg.anim.meta 88B
miner_face.anim.meta 88B
miner-appear.anim.meta 88B
miner-pull-fast.anim.meta 88B
obj-gold2.anim.meta 88B
miner-thorw.anim.meta 88B
obj-gold1.anim.meta 88B
miner-pull-light.anim.meta 88B
cave.anim.meta 88B
共 144 条
- 1
- 2
资源评论
- yefeng5192018-05-23不错的学习资源
- weixin_421855792018-05-18不错。。。。
- 金羽痕2018-12-01下载下来看看再说
- 小雨滴答滴答2020-05-13不错的学习资源
小熊孑
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功