// 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: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
pet: cc.Node,
clean: cc.Label,
physical: cc.Label,
mood: cc.Label,
button: cc.Node,
gold: cc.Label,
//mybag 预制资源
goodPanel: cc.Node,
myGood: cc.Prefab,
},
//背包资源预制
// spawnGoods() {
// this.goodsArray = []
// for (var i = 0; i < 1; i++) {
// let good = cc.instantiate(this.myGoods)
// good.getComponent('myGoods').initInfo(shopMenu.GOODS[i])
// this.goodsArray.push(good)
// this.goodPanel.addChild(good)
// console.log(shopMenu.GOODS.length)
// }
// },
//bag btn
bagBtn() {
if (this.goodPanel.parent.active) {
this.goodPanel.parent.active = false
} else {
this.goodPanel.parent.active = true
// this.spawnGoods()
// console.log('spawn success')
}
},
btn_callback(sender, infm) {
this.goldAdd()
var anim = this.pet.getComponent(cc.Animation);
if (infm === "eat") {
anim.play('animEat')
this.physicalValueAdd()
} else if (infm === "drink") {
anim.play('animDrink')
this.physicalValueAdd()
} else if (infm === "shower") {
anim.play('animWash')
this.cleanValueAdd()
} else if (infm === "study") {
anim.play('animStudy')
this.moodvalueAdd()
this.physicalValueSub()
} else if (infm === "work") {
anim.play('animWorking')
this.moodvalueAdd()
this.physicalValueSub()
} else if (infm === "goToWork") {
anim.play('animGoToWork')
this.moodvalueAdd()
this.physicalValueSub()
}
//允许单个动作进行
this.button.active = false
anim.on('finished', (msg) => {
this.button.active = true;
}, this)
//存储数据
var goldValue = this.goldValue
this.gold.string = this.goldValue;
cc.sys.localStorage.setItem('goldValue', JSON.stringify(this.goldValue));
var moodValue = this.moodValue
this.mood.string = "心情值:" + this.moodValue;
cc.sys.localStorage.setItem('moodValue', JSON.stringify(this.moodValue));
var cleanValue = this.cleanValue
this.clean.string = "清洁值:" + this.cleanValue;
cc.sys.localStorage.setItem('cleanValue', JSON.stringify(this.cleanValue));
var physicalValue = this.physicalValue
this.physical.string = "体力值:" + this.physicalValue;
cc.sys.localStorage.setItem('physicalValue', JSON.stringify(this.physicalValue));
},
// LIFE-CYCLE CALLBACKS:
onLoad() {
//全局化
window.game = this
//初始化属性值
this.moodValue = 0
this.cleanValue = 0
this.physicalValue = 0
this.goldValue = 0
//读取用户数据
this.goldValue = JSON.parse(cc.sys.localStorage.getItem('goldValue'))
this.gold.string = this.goldValue
this.moodValue = JSON.parse(cc.sys.localStorage.getItem('moodValue'))
this.mood.string = "心情值:" + this.moodValue
this.cleanValue = JSON.parse(cc.sys.localStorage.getItem('cleanValue'))
this.clean.string = "清洁值:" + this.cleanValue
this.physicalValue = JSON.parse(cc.sys.localStorage.getItem('physicalValue'))
this.physical.string = "体力值:" + this.physicalValue
this.bagBtn()
},
//gold value count
goldAdd() {
var goldValue
this.goldValue += 10;
},
//mood value count
moodvalueAdd() {
this.moodValue += 1;
this.mood.string = "心情值:" + this.moodValue;
},
moodvalueSub() {
this.moodValue -= 1;
this.mood.string = "心情值:" + this.moodValue;
},
//clean value count
cleanValueAdd() {
this.cleanValue += 1;
this.clean.string = "清洁值:" + this.cleanValue;
},
cleanValueSub() {
this.cleanValue -= 1;
this.clean.string = "清洁值:" + this.cleanValue;
},
//physical value count
physicalValueAdd() {
this.physicalValue += 1;
this.physical.string = "体力值:" + this.physicalValue;
},
physicalValueSub() {
this.physicalValue -= 1;
this.physical.string = "体力值:" + this.physicalValue;
},
start() {
},
// update (dt) {},
});
没有合适的资源?快使用搜索试试~ 我知道了~
企鹅宠物-creator.zip源码cocos creator项目源码下载
共137个文件
meta:70个
png:41个
anim:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 200 浏览量
2022-03-18
09:21:44
上传
评论
收藏 3.23MB ZIP 举报
温馨提示
企鹅宠物-creator.zip源码cocos creator项目源码下载企鹅宠物-creator.zip源码cocos creator项目源码下载 1.上线产品适合个人学习技术做项目参考 2.开发脚本为javsScropt或者typeScript 3.上线产品适合小公司开发游戏项目参考
资源推荐
资源详情
资源评论
收起资源包目录
企鹅宠物-creator.zip源码cocos creator项目源码下载 (137个子文件)
animWorking.anim 10KB
animEat.anim 9KB
animWash.anim 7KB
animGoToWork.anim 7KB
animStudy.anim 3KB
animDrink.anim 3KB
game.fire 148KB
start.fire 28KB
game.js 5KB
shopMenu.js 2KB
myGoods.js 2KB
start_btn.js 2KB
tsconfig.json 368B
jsconfig.json 266B
project.json 169B
services.json 63B
project.json 52B
workingpet.plist.meta 34KB
eatpet.plist.meta 32KB
washpet.plist.meta 24KB
petGotowork.plist.meta 22KB
studypet.plist.meta 9KB
drinkpet.plist.meta 8KB
massiveMultiplayer.png.meta 823B
start_btn.png.meta 820B
strawberryCookie.png.meta 820B
set_btn.png.meta 818B
audioOff.png.meta 817B
shoppingCart.png.meta 817B
settingPanel.png.meta 816B
bearCookies.png.meta 815B
audioOn.png.meta 814B
menuPanel.png.meta 813B
bg.png.meta 812B
gold.png.meta 812B
icecream.png.meta 812B
shopcar.png.meta 811B
yangtuo.png.meta 811B
cross.png.meta 810B
moquan.png.meta 810B
rank.png.meta 809B
studyBtn.png.meta 809B
bg.png.meta 809B
cross.png.meta 809B
coka.png.meta 808B
washBtn.png.meta 808B
keji.png.meta 808B
tutu.png.meta 808B
warning.png.meta 808B
dishbtn.png.meta 808B
workBtn.png.meta 808B
setbtn.png.meta 807B
eatBtn.png.meta 807B
bag.png.meta 807B
petbtn.png.meta 807B
dog.png.meta 804B
star.png.meta 802B
19.png.meta 800B
workingpet.png.meta 288B
eatpet.png.meta 287B
washpet.png.meta 287B
studypet.png.meta 287B
petGotowork.png.meta 287B
drinkpet.png.meta 286B
resources.meta 258B
animation.meta 250B
action.meta 250B
start.meta 250B
set.meta 250B
menu.meta 250B
game.meta 250B
scenes.meta 250B
script.meta 250B
game.js.meta 197B
myGoods.js.meta 197B
start_btn.js.meta 197B
shopMenu.js.meta 197B
myGoods.prefab.meta 169B
game.fire.meta 146B
start.fire.meta 145B
animEat.anim.meta 88B
animStudy.anim.meta 88B
animGoToWork.anim.meta 88B
animWorking.anim.meta 88B
animDrink.anim.meta 88B
font.TTF.meta 88B
animWash.anim.meta 88B
workingpet.plist 34KB
eatpet.plist 32KB
washpet.plist 24KB
petGotowork.plist 23KB
studypet.plist 9KB
drinkpet.plist 9KB
bg.png 340KB
eatpet.png 288KB
washpet.png 261KB
workingpet.png 163KB
petGotowork.png 155KB
bg.png 57KB
gold.png 43KB
共 137 条
- 1
- 2
资源评论
- qq_515202442023-04-30资源很好用,有较大的参考价值,资源不错,支持一下。
yxkfw
- 粉丝: 77
- 资源: 2万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功