添加一个简单的新手引导时,只能点击某个区域

This commit is contained in:
leo
2018-11-27 11:15:16 +08:00
parent 26f9a9ccb4
commit 4919101b09
23 changed files with 21900 additions and 0 deletions

View 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) {
},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View 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();
}
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "de4cbf96-53a1-41a7-a2cb-9a4b7cf00212",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}