| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // 角色逻辑控制
- var GameStates = require('GameStates');
- cc.Class({
- extends: cc.Component,
- properties: {
-
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.GameMode = this.node.parent.getComponent('GameMode')
- this.GameCanvas = this.node.parent.getComponent('GameCanvas')
- },
- start () {
- },
- onBeginContact: function (contact, selfCollider, otherCollider) {
- cc.log(otherCollider.node.name)
- if(otherCollider.node.name=='fruitPrefab'){
- this.GameMode.addTool(otherCollider.node)
- setTimeout(function(){
- otherCollider.node.destroy()
- }.bind(this),300)
- }
- if(otherCollider.node.name=='PipeBody'){
- this.node.getChildByName('Scream').active = true
- setTimeout(function(){
- this.node.getChildByName('Scream').active = false
- }.bind(this),1000)
- }
- if(otherCollider.node.name=='DestinationFlag'){
- this.GameCanvas.gameOver(1,GameStates.gameScore,GameStates.gameTime)
- this.node.getComponent(cc.RigidBody).gravityScale = 0
- this.node.getComponent(cc.RigidBody).linearVelocity = cc.v2(0,0)
- }
- },
- // onEndContact: function (contact, selfCollider, otherCollider) {
-
- // },
- });
|