大厅界面,完善quick close

This commit is contained in:
宝爷
2019-11-13 23:19:53 +08:00
committed by wyb10a10
parent 8b066b6713
commit ab9f027b8f
7 changed files with 226 additions and 89 deletions

View File

@@ -1,31 +1,21 @@
// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
import { UIView } from "../../ui/UIView";
import { uiManager } from "../../ui/UIManager";
import { UIID } from "../UIExample";
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
export default class UIHall extends UIView {
public onBag() {
uiManager.open(UIID.UIBag);
}
// update (dt) {}
public onNotice() {
uiManager.open(UIID.UINotice);
}
public onTop(preID: number, item: number) {
}
}

View File

@@ -8,6 +8,8 @@ const {ccclass, property} = cc._decorator;
export default class UILogin extends UIView {
public onLogin() {
uiManager.replace(UIID.UIHall);
// 连续打开2个界面
uiManager.open(UIID.UIHall);
uiManager.open(UIID.UINotice);
}
}

View File

@@ -234,15 +234,17 @@ export class UIManager {
// 快速关闭界面的设置绑定界面中的background实现快速关闭
if (uiView.quickClose) {
let backGround = uiView.node.getChildByName('background');
if (backGround) {
backGround.targetOff(cc.Node.EventType.TOUCH_START);
backGround.on(cc.Node.EventType.TOUCH_START, (event: cc.Event.EventCustom) => {
event.stopPropagation();
this.close(uiView);
}, backGround);
} else {
cc.log(`onUIOpen ${uiId} quickClose faile, background node not found!`);
if (!backGround) {
backGround = new cc.Node()
backGround.name = 'background';
backGround.setContentSize(cc.winSize);
uiView.node.addChild(backGround, -1);
}
backGround.targetOff(cc.Node.EventType.TOUCH_START);
backGround.on(cc.Node.EventType.TOUCH_START, (event: cc.Event.EventCustom) => {
event.stopPropagation();
this.close(uiView);
}, backGround);
}
// 添加到场景中

View File

@@ -47,10 +47,13 @@
},
{
"__id__": 38
},
{
"__id__": 39
}
],
"_prefab": {
"__id__": 39
"__id__": 40
},
"_opacity": 255,
"_color": {
@@ -1478,6 +1481,19 @@
"_originalHeight": 100,
"_id": ""
},
{
"__type__": "fca327d1KhLiq6nzIlLgtCj",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"quickClose": false,
"cache": false,
"showType": 2,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@@ -24,24 +24,27 @@
"__id__": 5
},
{
"__id__": 15
"__id__": 8
},
{
"__id__": 18
}
],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 25
"__id__": 28
},
{
"__id__": 26
"__id__": 29
},
{
"__id__": 27
"__id__": 30
}
],
"_prefab": {
"__id__": 28
"__id__": 31
},
"_opacity": 255,
"_color": {
@@ -89,7 +92,7 @@
},
{
"__type__": "cc.Node",
"_name": "weapon",
"_name": "weapon_bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
@@ -115,8 +118,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -125,8 +128,8 @@
},
"_position": {
"__type__": "cc.Vec3",
"x": -283,
"y": 126,
"x": -194.429,
"y": 87.429,
"z": 0
},
"_scale": {
@@ -165,10 +168,10 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
"__uuid__": "1bfb1bd7-09ff-449e-a039-0dd80ebdde4a"
},
"_type": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
@@ -178,7 +181,9 @@
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": {
"__uuid__": "ce0fb307-84f4-4841-a0ec-4b0960e7ba6e"
},
"_id": ""
},
{
@@ -192,6 +197,113 @@
"fileId": "73jYudLNhCiY+y6aMxHNv1",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "weapon",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": -194.429,
"y": 87.429,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_rotationX": 0,
"_rotationY": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "1bfb1bd7-09ff-449e-a039-0dd80ebdde4a"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": {
"__uuid__": "ce0fb307-84f4-4841-a0ec-4b0960e7ba6e"
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "cb6fb71a-9a7f-4197-b686-362c0521d8a1"
},
"fileId": "3am8UA8W9JR5nkOfEWLQCn",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "button",
@@ -201,18 +313,18 @@
},
"_children": [
{
"__id__": 6
"__id__": 9
}
],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 13
"__id__": 16
}
],
"_prefab": {
"__id__": 14
"__id__": 17
},
"_opacity": 255,
"_color": {
@@ -263,25 +375,25 @@
"_name": "Background",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 8
},
"_children": [
{
"__id__": 7
"__id__": 10
}
],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 10
"__id__": 13
},
{
"__id__": 11
"__id__": 14
}
],
"_prefab": {
"__id__": 12
"__id__": 15
},
"_opacity": 255,
"_color": {
@@ -332,18 +444,18 @@
"_name": "Label",
"_objFlags": 0,
"_parent": {
"__id__": 6
"__id__": 9
},
"_children": [],
"_active": true,
"_level": 3,
"_components": [
{
"__id__": 8
"__id__": 11
}
],
"_prefab": {
"__id__": 9
"__id__": 12
},
"_opacity": 255,
"_color": {
@@ -394,7 +506,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
"__id__": 10
},
"_enabled": true,
"_materials": [
@@ -435,7 +547,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 9
},
"_enabled": true,
"_materials": [
@@ -467,7 +579,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 9
},
"_enabled": true,
"alignMode": 0,
@@ -505,7 +617,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
"__id__": 8
},
"_enabled": true,
"duration": 0.1,
@@ -576,7 +688,7 @@
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
"_N$target": {
"__id__": 6
"__id__": 9
},
"_id": ""
},
@@ -600,18 +712,18 @@
},
"_children": [
{
"__id__": 16
"__id__": 19
}
],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 23
"__id__": 26
}
],
"_prefab": {
"__id__": 24
"__id__": 27
},
"_opacity": 255,
"_color": {
@@ -662,25 +774,25 @@
"_name": "Background",
"_objFlags": 0,
"_parent": {
"__id__": 15
"__id__": 18
},
"_children": [
{
"__id__": 17
"__id__": 20
}
],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 20
"__id__": 23
},
{
"__id__": 21
"__id__": 24
}
],
"_prefab": {
"__id__": 22
"__id__": 25
},
"_opacity": 255,
"_color": {
@@ -731,18 +843,18 @@
"_name": "Label",
"_objFlags": 0,
"_parent": {
"__id__": 16
"__id__": 19
},
"_children": [],
"_active": true,
"_level": 3,
"_components": [
{
"__id__": 18
"__id__": 21
}
],
"_prefab": {
"__id__": 19
"__id__": 22
},
"_opacity": 255,
"_color": {
@@ -793,7 +905,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
"__id__": 20
},
"_enabled": true,
"_materials": [
@@ -802,8 +914,8 @@
}
],
"_useOriginalSize": false,
"_string": "button",
"_N$string": "button",
"_string": "公告",
"_N$string": "公告",
"_fontSize": 20,
"_lineHeight": 40,
"_enableWrapText": false,
@@ -834,7 +946,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 19
},
"_enabled": true,
"_materials": [
@@ -866,7 +978,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 19
},
"_enabled": true,
"alignMode": 0,
@@ -904,7 +1016,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
"__id__": 18
},
"_enabled": true,
"duration": 0.1,
@@ -975,7 +1087,7 @@
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
"_N$target": {
"__id__": 16
"__id__": 19
},
"_id": ""
},
@@ -1057,8 +1169,9 @@
"__id__": 1
},
"_enabled": true,
"label": null,
"text": "hello",
"quickClose": false,
"cache": false,
"showType": 0,
"_id": ""
},
{

View File

@@ -28,11 +28,11 @@
"_level": 1,
"_components": [
{
"__id__": 15
"__id__": 16
}
],
"_prefab": {
"__id__": 16
"__id__": 17
},
"_opacity": 255,
"_color": {
@@ -201,7 +201,7 @@
}
],
"_prefab": {
"__id__": 14
"__id__": 15
},
"_opacity": 255,
"_color": {
@@ -499,7 +499,11 @@
"_enabled": true,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"clickEvents": [
{
"__id__": 14
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 2,
@@ -569,6 +573,16 @@
},
"_id": ""
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "969aczWd9lHOpX3wou4IN95",
"handler": "onLogin",
"customEventData": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@@ -40,9 +40,9 @@
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 66,
"g": 65,
"b": 70,
"r": 79,
"g": 138,
"b": 57,
"a": 255
},
"_contentSize": {