import PanelBase from 'PanelBase';
import YouYou from './YouYou';
cc.Class({
extends: PanelBase,
properties: {
speed: cc.v2(0, 0),
maxSpeed: cc.v2(1000, 1000),
gravity: -9000,
drag: 1000,
direction: 0, //人物方向,释放鼠标会归零 -1: 左 1:右
jumpSpeed: 500,
jumpCount: 0, //跳跃次数 落地之后才可以再跳
hunker: false,//是否蹲下
getScore: 0,
isDied: false,
fallDown: false, //是否为下落状态
life: 1, //角色生命值
buttonIsPressed: false,//左右键盘是否被摁下
_stopDir: 0, //释放按键缓冲后方向 -1: 左 1:右
_speedIndex: 0,
_beginPosX: 0, //开始点击按键人物X坐标
_arrSpeed: [],
_holdClick: false, //用来检测点击
_holdTimeEclipse: 0, //用来检测长按还是短按
_bLongPress: false, //是否长按
_bInBounce: false, //是否在按着方向键
camera: {
default: null,
type: cc.Node,
},
deadPrefab: {
type: cc.Prefab,
default: null,
},
},
onLoad() {
this.collisionX = this.collisionY = this.touchingNumber = this._speedIndex = 0;
this._arrSpeed = [1000, 300, 0.001];
this._bLongPress = this._holdClick = this._bInBounce = false;
this._holdTimeEclipse = 0;
},
reStart() {
},
onDestroy() {
},
noDownControlPlayer() {
if (this.touchingNumber === 0) {
return;
}
if (!this.isDied) {
if (this.direction !== 0) {
this.player_walk();
} else {
this.player_idle();
}
this.hunker = false;
}
},
noLRControlPlayer() {
this.direction = 0;
this._bInBounce = false;
//this._speedIndex = 0;
if (!this.isDied && this.jumpCount == 0)//jumpCount 跳跃次数 落地为0 落地之后才可以再跳
{
//console.log("player缓冲了!!!");
this.player_cushion();
if (this.node) {
this._beginPosX = this.node.x;
}
this._holdClick = false;
}
this.buttonIsPressed = false;
//console.log("holdTimeEclipse: " + this._holdTimeEclipse);
if(this._holdTimeEclipse>=30)
{
this._bLongPress = true;
}
},
noUpControlPlayer() {
//console.log("noUpControlPlayer")
//console.log("noUpControlPlayer*******: " + this.touchingNumber);
this._bInBounce = false;
if (this.touchingNumber == 0) {
// this.jumping = false; //是否在跳状态
//console.log("释放上键点击******: " + this.speed.x);
//this.player_idle();
}
},
playerLeft() {
if (!this.node || this.jumping) return;
if (this.direction !== -1 && this.jumpCount == 0 && !this.isDied) {
this._holdClick = true;
this._bInBounce = false;
this.player_walk();
}
this.buttonIsPressed = true;
this.turnLeft();
this.direction = -1;
},
turnLeft() {
this.node.getComponent(cc.Animation).play("leftrun");
},
playerRight() {
if (!this.node || this.jumping) return;
if (this.direction !== 1 && this.jumpCount == 0 && !this.isDied) {
this._holdClick = true;
this._bInBounce = false;
this.player_walk();
}
this.buttonIsPressed = true;
this.turnRight();
this.direction = 1;
},
turnRight() {
this.node.getComponent(cc.Animation).play("rightrun");
},
playerUp() {
//console.log('this.jumping: ' + this.jumping);
//console.log('this.jumpCount: ' + this.jumpCount);
if (!this.node) return;
this.jumpCount++;
//this.speed.y >= 0 //需要上升到一定高度再跳
if (!this.jumping && this.jumpCount <= 2 && !this.isDied)// 如果活着的没在跳跃状态,并且玩家着地
{
this.player_jump();
if (this.speed) {
this.speed.y = this.jumpSpeed * 0.65;
}
//this.jumping = true;
}
},
playerDown() {
if (this.touchingNumber === 0) {
return;
}
if (!this.hunker && !this.isDied) {
this.player_hunker();
this.hunker = true;
}
},
player_cushion() {
//console.log("player_cushion");
if (this.node) {
if (this.speed.x < 0) {
this.node.getComponent(cc.Animation).play("leftrun");
}else if(this.speed.x > 0) {
this.node.getComponent(cc.Animation).play("rightrun");
}
}
},
player_idle() {
//this.anim.play("player_idle");
//console.log("speed x: " + this.speed.x);
if (this.node) {
if (this.speed.x < 0) {
this.node.getComponent(cc.Animation).play("leftstand");
}else if(this.speed.x > 0) {
this.node.getComponent(cc.Animation).play("rightstand");
}
}
},
player_walk() {
//this.anim.play("player_walk");
if (this.node) {
if (this.speed.x < 0) {
this.node.getComponent(cc.Animation).play("leftrun");
}else if(this.speed.x > 0) {
this.node.getComponent(cc.Animation).play("rightrun");
}
}
},
player_jump() {
//console.log("currrent clip ******");
var curClipName = this.node.getComponent(cc.Animation).currentClip.name;
if (curClipName == 'rightstand' || curClipName == 'rightrun') {
this.node.getComponent(cc.Animation).play("rightrun");
}else if(curClipName == 'leftstand' || curClipName == 'leftrun') {
this.node.getComponent(cc.Animation).play("leftrun");
}
},
player_hunker() {
//this.anim.play("player_hunker");
},
rabbitJump() {//玩家踩到敌人的跳跃
//this.anim.play("player_jump");
this.speed.y = this.jumpSpeed * 0.5;
},
rabbitDieJump() {
//cc.audioEngine.play(this.dieAudio, false, Global.volume);
//this.anim.play("player_die");
this.speed.y = this.jumpSpeed;
cc.director.getCollisionManager().enabled = false;
this.touchingNumber = 0;
this.isDied = true;
this.life = 0;
//this.node.parent.getComponent('Cameras').isRun = false;
//Global.playIsAlive = false;
//setTimeout(() => { this.node.destroy() }, 2100)
},
OverNodeLoad() {
// if (this.life == 0) {
// this.scheduleOnce(function () {
// // 这里的 this 指向 component
// cc.find('over').active = true;
// }, 2);
// }
},
onCollisionEnter: function (other, self) {
//console.log("other name***************: " + other.node.name);
//console.log("other tag***************: " + other.tag);
if (this.touchingNumber == 0) {
if (this.buttonIsPressed) // 左右按键
this.player_walk();// 有按键时,快要落地之前为walk状态
else
this.player_idle();// 没有按键时,快要落地之前为idle状态
}
switch (other.tag) {
case 0:
this.collisionPlatformEnter(other, self);
break;
case 1:
this.collisionFireEnter(other, self);
break;
case 3:
this.collisionMonkeyEnter(other, self);
break;
case 4:
this.collisionHoleEnter(other, self);
break;
case 6:
console.log("yuliu");
没有合适的资源?快使用搜索试试~ 我知道了~
小熊快跑creator.zip源码cocos creator项目源码下载
共568个文件
meta:299个
png:201个
js:28个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 57 浏览量
2022-03-18
11:03:40
上传
评论
收藏 8.87MB ZIP 举报
温馨提示
小熊快跑creator.zip源码cocos creator项目源码下载小熊快跑creator.zip源码cocos creator项目源码下载 1.上线产品适合个人学习技术做项目参考 2.开发脚本为javsScropt或者typeScript 3.上线产品适合小公司开发游戏项目参考
资源推荐
资源详情
资源评论
收起资源包目录
小熊快跑creator.zip源码cocos creator项目源码下载 (568个子文件)
holefireeffect.anim 7KB
flowermouth.anim 4KB
flowerbite.anim 2KB
rightrun.anim 2KB
leftrun.anim 2KB
penfireeffect.anim 2KB
leftwing.anim 876B
rightwing.anim 875B
rightfire1.anim 623B
leftfire1.anim 622B
rightstand.anim 622B
leftstand.anim 621B
Game.fire 152KB
Home.fire 83KB
Level.fire 17KB
Loading.fire 13KB
ui.jpg 422KB
2.jpg 396KB
Player.js 23KB
Game.js 19KB
OsUtil.js 18KB
index.js 10KB
OsServer.js 7KB
OsLoader.js 7KB
Monkey.js 6KB
OS.js 6KB
Loading.js 6KB
OsLocalStorage.js 5KB
OsAudio.js 4KB
OsJsonData.js 4KB
Level.js 3KB
Base.js 2KB
Flower.js 2KB
FloatTile.js 2KB
Config.js 2KB
YouYou.js 2KB
FireCircle.js 1KB
PanelBase.js 1KB
Home.js 1KB
BoneBase.js 925B
HoleControl.js 729B
SceneBase.js 694B
PowerNode.js 565B
main.js 558B
Banzhuan.js 544B
TipsLabel.js 402B
project.json 3KB
osjson.json 2KB
builder.json 1007B
package.json 551B
tsconfig.json 368B
jsconfig.json 266B
project.json 148B
services.json 63B
LabelAtlas.labelatlas 35B
shirenhua_xiangqianyao_08.png.meta 838B
shirenhua_xiangqianyao_10.png.meta 838B
shirenhua_xiangqianyao_04.png.meta 838B
shirenhua_xiangqianyao_02.png.meta 838B
shirenhua_xiangqianyao_01.png.meta 837B
shirenhua_xiangqianyao_09.png.meta 836B
shirenhua_xiangqianyao_05.png.meta 835B
shirenhua_xiangqianyao_06.png.meta 834B
shirenhua_xiangqianyao_07.png.meta 834B
shirenhua_xiangqianyao_00.png.meta 834B
shirenhua_xiangqianyao_03.png.meta 833B
xionger_zuomian-pao_07.png.meta 832B
xionger_zuomian-pao_07.png.meta 832B
xionger_youmian-pao_04.png.meta 832B
xionger_youmian-pao_04.png.meta 832B
xionger_zuomian-pao_05.png.meta 831B
xionger_zuomian-pao_04.png.meta 831B
xionger_zuomian-pao_01.png.meta 831B
xionger_zuomian-pao_02.png.meta 831B
xionger_zuomian-pao_05.png.meta 831B
xionger_zuomian-pao_04.png.meta 831B
xionger_zuomian-pao_01.png.meta 831B
xionger_zuomian-pao_02.png.meta 831B
xionger_youmian-pao_03.png.meta 831B
xionger_youmian-pao_07.png.meta 831B
xionger_youmian-pao_03.png.meta 831B
xionger_youmian-pao_07.png.meta 831B
xionger_zuomian-pao_08.png.meta 830B
xionger_zuomian-pao_09.png.meta 830B
xionger_zuomian-pao_03.png.meta 830B
xionger_zuomian-pao_08.png.meta 830B
xionger_zuomian-pao_09.png.meta 830B
xionger_zuomian-pao_03.png.meta 830B
xionger_youmian-pao_02.png.meta 830B
xionger_youmian-pao_06.png.meta 830B
xionger_youmian-pao_00.png.meta 830B
xionger_youmian-pao_01.png.meta 830B
xionger_youmian-pao_05.png.meta 830B
xionger_youmian-pao_09.png.meta 830B
xionger_youmian-pao_02.png.meta 830B
xionger_youmian-pao_06.png.meta 830B
xionger_youmian-pao_00.png.meta 830B
xionger_youmian-pao_01.png.meta 830B
xionger_youmian-pao_05.png.meta 830B
xionger_youmian-pao_09.png.meta 830B
共 568 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
yxkfw
- 粉丝: 76
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功