Commit a456cd7e by william

feat: init Game.js

parent ec69a80b
......@@ -68,17 +68,20 @@
"__id__": 9
},
{
"__id__": 11
"__id__": 14
},
{
"__id__": 13
"__id__": 16
}
],
"_tag": -1,
"_active": true,
"_components": [
{
"__id__": 15
"__id__": 18
},
{
"__id__": 19
}
],
"_prefab": null,
......@@ -308,7 +311,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 160,
"height": 80
"height": 120
},
"_rotationX": 0,
"_rotationY": 0,
......@@ -342,7 +345,7 @@
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_N$string": "在下课前快速撩妹\n避免被老师发现",
"_N$string": "点击屏幕开始撩妹\n在下课前快速撩妹\n避免被老师发现",
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
......@@ -350,17 +353,24 @@
},
{
"__type__": "cc.Node",
"_name": "btn-start",
"_name": "start_btn",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_children": [
{
"__id__": 10
}
],
"_tag": -1,
"_active": true,
"_components": [
{
"__id__": 10
"__id__": 12
},
{
"__id__": 13
}
],
"_prefab": null,
......@@ -401,6 +411,68 @@
"groupIndex": 0
},
{
"__type__": "cc.Node",
"_name": "Start",
"_objFlags": 0,
"_parent": {
"__id__": 9
},
"_children": [],
"_tag": -1,
"_active": true,
"_components": [
{
"__id__": 11
}
],
"_prefab": null,
"_id": "f6tbdlSzFHwKHIkKiKfGBl",
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_cascadeOpacityEnabled": true,
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_rotationX": 0,
"_rotationY": 0,
"_scaleX": 1,
"_scaleY": 1,
"_position": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 0,
"_globalZOrder": 0,
"_opacityModifyRGB": false,
"groupIndex": 0
},
{
"__type__": "729abdON3JFXqpKBchOOYfX",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"isOpenGame": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
......@@ -427,6 +499,16 @@
"_atlas": null
},
{
"__type__": "729abdON3JFXqpKBchOOYfX",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"isOpenGame": false
},
{
"__type__": "cc.Node",
"_name": "classroom",
"_objFlags": 0,
......@@ -435,10 +517,10 @@
},
"_children": [],
"_tag": -1,
"_active": true,
"_active": false,
"_components": [
{
"__id__": 12
"__id__": 15
}
],
"_prefab": null,
......@@ -483,7 +565,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
"__id__": 14
},
"_enabled": true,
"_spriteFrame": {
......@@ -516,7 +598,7 @@
"_active": true,
"_components": [
{
"__id__": 14
"__id__": 17
}
],
"_prefab": null,
......@@ -561,7 +643,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
"__id__": 16
},
"_enabled": true,
"_spriteFrame": {
......@@ -597,5 +679,35 @@
},
"_fitWidth": false,
"_fitHeight": true
},
{
"__type__": "e4c9b01WKRDtYbVX2Ed1Nfl",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"score": 0,
"time": 60,
"leftLife": 3,
"swivelAnimationTime": 0.2,
"flirtAnimationTime": 0.2,
"gameState": "waiting",
"logo": {
"__id__": 5
},
"subtitle": {
"__id__": 7
},
"start_btn": {
"__id__": 9
},
"classroom": {
"__id__": 14
},
"hand": {
"__id__": 16
}
}
]
\ No newline at end of file
......@@ -5,7 +5,7 @@
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"btn-start": {
"start_btn": {
"ver": "1.0.3",
"uuid": "39ffe8bc-c233-4562-94b9-3c2f2c82b452",
"rawTextureUuid": "ac77b207-d6ae-4829-acdc-352b6e8a2153",
......
// Learn cc.Class:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/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;
// }
// },
/** 游戏节点的注册 */
// logo节点
logo: {
default: null,
type: cc.Node,
},
// subtitle节点
subtitle: {
default: null,
type: cc.Node,
},
// btn_start节点
start_btn: {
default: null,
type: cc.Node,
},
// classroom节点
classroom: {
default: null,
type: cc.Node,
},
// hand节点
hand: {
default: null,
type: cc.Node,
},
},
onLoad: function () {
// 初始化游戏数据
this.score = 0; // 分数
this.timer = 60; // 每一盘游戏的总时间
this.leftLife = 3; // 剩余的命条数
this.gameState = "waitting"; // 游戏的状态 waiting(待开始) action(游戏中) stop(被抓) over(分数总结)
this.swivelAnimationTime = 0.5; //转头动画时间 (单向)
this.flirtAnimationTime = 0.5; //摸的动画时间(单向)
// 奖Game组件的实例传入开始按钮
var startBtn = this.node.getChildByName("start_btn");
startBtn.getComponent('Start').game = this;
},
// 添加分数
gainScore: function() {
this.score += 1;
},
// 游戏帧循环
update: function(dt) {
},
// LIFE-CYCLE CALLBACKS:
// 游戏开始
startGame: function() {
// onLoad () {},
},
start () {
// 游戏暂停
stopGame: function() {
},
// update (dt) {},
// 游戏结束
gameOver: function() {
},
});
cc.Class({
extends: cc.Component,
properties: {
isOpenGame: false
},
setTouchBtnListener: function () {
var self = this;
self.node.on(cc.Node.EventType.MOUSE_DOWN, function (event) {
self.game.classroom.active = true
})
},
onLoad: function () {
// 初始化跳跃动作
this.setTouchBtnListener()
},
});
{
"ver": "1.0.5",
"uuid": "729ab74e-3772-455e-aa4a-05c84e3987d7",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment