Created
March 5, 2019 05:16
-
-
Save ngocbd/a3fd4bbee6c97261ee10b395ffe08853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. | |
http://www.cocos2d-x.org | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. | |
****************************************************************************/ | |
var GameLayer = cc.Layer.extend({ | |
bogay:null, | |
ctor:function () { | |
////////////////////////////// | |
// 1. super init first | |
this._super(); | |
this.bogay = new Bogay(); | |
this.addChild(this.bogay, 0); | |
if( true || 'touches' in cc.sys.capabilities ) { | |
cc.eventManager.addListener(cc.EventListener.create({ | |
event: cc.EventListener.TOUCH_ALL_AT_ONCE, | |
onTouchesBegan: function(touches, event) { | |
var touch = touches[0]; | |
var loc = touch.getLocation(); | |
this.touchStartPoint = { | |
x: loc.x, | |
y: loc.y | |
}; | |
}, | |
onTouchesEnded: function(touches, event) { | |
console.log("onTouchesEnd"); | |
var touch = touches[0]; | |
var loc = touch.getLocation(); | |
event.getCurrentTarget().bogay.vX=5; | |
console.log("onTouchesBegin : "+this.touchStartPoint.x+ ","+this.touchStartPoint.y); | |
console.log("onTouchesEnd : "+loc.x+ ","+loc.y); | |
}, | |
} | |
), this); | |
} else { | |
cc.log("TOUCH_ALL_AT_ONCE is not supported"); | |
} | |
return true; | |
} | |
}); | |
var SexyGirlLayer = cc.Layer.extend({ | |
sprite:null, | |
ctor:function (level) { | |
this._super(); | |
this.sprite = new cc.Sprite(res.Level1); | |
var size = cc.winSize; | |
this.sprite.attr({ | |
x: size.width / 2, | |
y: size.height / 2 | |
}); | |
this.addChild(this.sprite, 0); | |
return true; | |
} | |
}); | |
var GameScene = cc.Scene.extend({ | |
onEnter:function () { | |
this._super(); | |
var gamelayer = new GameLayer(); | |
var girlLayer = new SexyGirlLayer(); | |
this.addChild(girlLayer); | |
this.addChild(gamelayer); | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment