基本完善一个新手引导页面

This commit is contained in:
leo
2018-11-27 13:28:49 +08:00
parent 5d3c99fb24
commit 60f0313a9b
5 changed files with 290 additions and 17 deletions

View File

@@ -3,32 +3,70 @@ cc.Class({
properties: {
nodeTarget: cc.Node,
nodeMark: cc.Node,
nodeMarkBg: cc.Node
},
onLoad() {
this.registerEvent();
this.node.on('touchstart', this.onTouchStart, this);
this.init();
},
registerEvent() {
},
init(data) {
this.setBoxBounding();
this.node.on('touchstart', this.onTouchStart, this);
this.initMarKPos(this.nodeTarget.convertToWorldSpaceAR(cc.v2(0, 0)));
},
initMarKPos(posWorld) {
let parent = this.node.parent || this.node;
let posLocal = parent.convertToNodeSpaceAR(posWorld);
this.nodeMark.setPosition(posLocal);
let size = this.getMaxLen(this.nodeTarget);
this.nodeMark.width = size;
this.nodeMark.height = size;
posLocal.x -= 0;
posLocal.y -= 0;
this.nodeMarkBg.setPosition(cc.v2(-posLocal.x, -posLocal.y));
},
getMaxLen(node) {
let size = node.width;
if (size < node.height) {
size = node.height;
}
return size;
},
/**
* 设置触摸区域
*/
setBoxBounding() {
let visiSize = cc.director.getVisibleSize();
this.node.width = visiSize.width;
this.node.height = visiSize.height;
},
/**
* 设置 touch 事件
* @param {*} event
*/
onTouchStart(event) {
let touchPos = event.getLocation();
console.log('touchPos=', touchPos);
let retWorld = this.nodeTarget.getBoundingBoxToWorld();
if (retWorld.contains(touchPos)) {
this.node._touchListener.setSwallowTouches(false);
this.node.active = false;
} else {
this.node._touchListener.setSwallowTouches(true);
}
},
init(data) {
},
update(dt) {
},

View File

@@ -0,0 +1,22 @@
cc.Class({
extends: cc.Component,
properties: {},
// LIFE-CYCLE CALLBACKS:
onLoad() {
//获取运行场景的可见大小。
let visiSize = cc.director.getVisibleSize();
this.node.width = visiSize.width;
this.node.height = visiSize.height;
// this.node.setAnchorPoint(0, 0);
this.node.color = cc.hexToColor("#000000");
this.node.opacity = 100;
},
start() {},
// update (dt) {},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "517f8516-ec12-48f6-8182-bc7aa58636fc",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}