mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-31 22:49:23 +08:00
添加一个简单的新手引导时,只能点击某个区域
This commit is contained in:
30
GuideDemo/assets/Script/HelloWorld.js
Normal file
30
GuideDemo/assets/Script/HelloWorld.js
Normal file
@@ -0,0 +1,30 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
label: {
|
||||
default: null,
|
||||
type: cc.Label
|
||||
},
|
||||
// defaults, set visually when attaching this script to the Canvas
|
||||
text: 'Hello, World!'
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
this.label.string = this.text;
|
||||
},
|
||||
|
||||
onEventClicked_can() {
|
||||
console.log('onEventClicked_can');
|
||||
},
|
||||
|
||||
onEventClicked_no() {
|
||||
console.log('onEventClicked_no');
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
9
GuideDemo/assets/Script/HelloWorld.js.meta
Normal file
9
GuideDemo/assets/Script/HelloWorld.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
43
GuideDemo/assets/Script/MarkTouch.js
Normal file
43
GuideDemo/assets/Script/MarkTouch.js
Normal file
@@ -0,0 +1,43 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
nodeTarget: cc.Node,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.registerEvent();
|
||||
this.node.on('touchstart', this.onTouchStart, this);
|
||||
},
|
||||
|
||||
registerEvent() {
|
||||
|
||||
},
|
||||
|
||||
onTouchStart(event) {
|
||||
let touchPos = event.getLocation();
|
||||
console.log('touchPos=', touchPos);
|
||||
let retWorld = this.nodeTarget.getBoundingBoxToWorld();
|
||||
if (retWorld.contains(touchPos)) {
|
||||
this.node._touchListener.setSwallowTouches(false);
|
||||
} else {
|
||||
this.node._touchListener.setSwallowTouches(true);
|
||||
}
|
||||
},
|
||||
|
||||
init(data) {
|
||||
|
||||
},
|
||||
|
||||
update(dt) {
|
||||
|
||||
},
|
||||
|
||||
offEvent() {
|
||||
|
||||
},
|
||||
|
||||
onDestroy() {
|
||||
this.offEvent();
|
||||
}
|
||||
});
|
||||
9
GuideDemo/assets/Script/MarkTouch.js.meta
Normal file
9
GuideDemo/assets/Script/MarkTouch.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "de4cbf96-53a1-41a7-a2cb-9a4b7cf00212",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user