mirror of
				https://github.com/blanking003/cx-cocos.git
				synced 2025-10-30 19:05:30 +00:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										130
									
								
								cx3-demo/assets/script/page/home.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								cx3-demo/assets/script/page/home.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,130 @@ | ||||
| import {_decorator, Component, Node, Sprite, Label} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('home') | ||||
| class Home extends Component  | ||||
| { | ||||
| 	start ()  | ||||
| 	{ | ||||
| 		cx.log("Home start..."); | ||||
| 		cx.gn(this, "spShowPage").setTouchCallback(this, this.showPage, "ui/pageChild"); | ||||
| 		cx.gn(this, "spHint").setTouchCallback(this, this.hint); | ||||
| 		cx.gn(this, "spAlert").setTouchCallback(this, this.alert); | ||||
| 		cx.gn(this, "spConfirm").setTouchCallback(this, this.confirm); | ||||
| 		cx.gn(this, "spShowLoading").setTouchCallback(this, this.showLoading); | ||||
| 		cx.gn(this, "spRemoveLoading").setTouchCallback(this, this.removeLoading); | ||||
| 		cx.gn(this, "spPageScrollView").setTouchCallback(this, this.showPage, "ui/pageScrollView"); | ||||
| 		cx.gn(this, "spPageBanner").setTouchCallback(this, this.showPage, "ui/pageBanner"); | ||||
| 		cx.gn(this, "spPicker").setTouchCallback(this, this.showPage, "ui/pagePicker"); | ||||
| 		cx.gn(this, "spLoadRemoteImage").setTouchCallback(this, this.loadRemoteImage); | ||||
| 		cx.gn(this, "spNative1").setTouchCallback(this, this.callNative1); | ||||
| 		cx.gn(this, "spNative2").setTouchCallback(this, this.callNative2); | ||||
| 		cx.gn(this, "spVideo").setTouchCallback(this, this.showPage, "ui/pageVideo"); | ||||
|  | ||||
| 		this.scheduleOnce(cx.removeLaunchImage, 0.3); | ||||
| 	} | ||||
| 	 | ||||
| 	showPage (sender: Node, page:string) | ||||
| 	{ | ||||
| 		cx.showPage(page); | ||||
| 	} | ||||
|  | ||||
| 	hint () | ||||
| 	{ | ||||
| 		cx.hint("cx.hint(content)"); | ||||
| 	} | ||||
|  | ||||
| 	alert () | ||||
| 	{ | ||||
| 		cx.alert("cx.alert(content, callback, labelOk)"); | ||||
| 	} | ||||
|  | ||||
| 	confirm () | ||||
| 	{ | ||||
| 		cx.confirm("cx.confirm(content, callback, labelOk, labelCancel)", cx.hint); | ||||
| 	} | ||||
|  | ||||
| 	showLoading (sender: Node) | ||||
| 	{ | ||||
| 		sender.getChildByName("label")!.getComponent(Label)!.string = ""; | ||||
| 		cx.showLoading(this, sender); | ||||
| 		//在查询服务中,一般使用延迟0.5秒执行: | ||||
| 		//cx.showLoading(this, sender, 0.5); | ||||
| 	} | ||||
|  | ||||
| 	removeLoading () | ||||
| 	{ | ||||
| 		cx.gn(this, "spShowLoading").getChildByName("label")!.getComponent(Label)!.string = "cx.showLoading"; | ||||
| 		cx.removeLoading(cx.gn(this, "spShowLoading")); | ||||
| 	} | ||||
|  | ||||
| 	loadRemoteImage () | ||||
| 	{ | ||||
| 		if (cx.os.native) | ||||
| 		{ | ||||
| 			var url = "https://www.cocos.com/wp-content/themes/cocos/image/logo.png"; | ||||
| 			//从远程取图片, localPath: 保存到本地路径,并优先从该路径取图片 | ||||
| 			cx.res.setImageFromRemote(cx.gn(this, "spLoadRemoteImage"), url, cx.sys.cachePath + "cocos_logo.png", Sprite.SizeMode.TRIMMED); | ||||
| 		} | ||||
| 		else | ||||
| 			cx.hint("only for native!"); | ||||
|  | ||||
| 		// 从resources目录取图片: | ||||
| 		// cx.res.setImageFromRes(cx.gn(this, "spLoadRemoteImage"), "xx", Sprite.SizeMode.CUSTOM, callback); | ||||
|  | ||||
| 		// 从bundle目录取图片 | ||||
| 		// cx.res.setImageFromBundle(cx.gn(this, "spLoadRemoteImage"), "cx.prefab/s_loading", Sprite.SizeMode.CUSTOM, callback); | ||||
|  | ||||
| 		// 上传图片: | ||||
| 		// cx.serv.upload("http://localhost:7300/cxserv/app/system/uploadFile", cx.sys.cachePath + "a1.png"); | ||||
| 	} | ||||
|  | ||||
| 	callNative1 () | ||||
| 	{ | ||||
| 		if (cx.os.native) | ||||
| 		{ | ||||
| 			// ex: cx.native.ins("接口名").call("函数名", [参数], this.callNativeCallback.bind(this)); | ||||
| 			// 回调函数:callNativeCallback (number, string) | ||||
|  | ||||
| 			var ret = cx.native.ins("cx.sys").call("getPackageName", []); | ||||
| 			cx.hint("native return: " + ret); | ||||
| 		} | ||||
| 		else | ||||
| 			cx.hint("only for native!"); | ||||
| 	} | ||||
|  | ||||
| 	callNative2 () | ||||
| 	{ | ||||
| 		if (cx.os.ios || cx.os.android) | ||||
| 			cx.native.ins("system").call("callPhone", ["10000"]); | ||||
| 		else | ||||
| 			cx.hint("only for ios or android!"); | ||||
| 	} | ||||
|  | ||||
| 	// location () | ||||
| 	// { | ||||
| 	// 	if (cx.os.ios || cx.os.android) | ||||
| 	// 	{ | ||||
| 	// 		cx.showLoading(this, this.node, 0.5); | ||||
| 	// 		cx.native.ins("amapLocation").call("location", [true], this.locationCallback.bind(this)); | ||||
| 	// 	} | ||||
| 	// 	else | ||||
| 	// 		cx.hint("only for ios or android!"); | ||||
| 	// } | ||||
|  | ||||
| 	// locationCallback (succ: number, info: string) | ||||
| 	// { | ||||
| 	// 	cx.removeLoading(this.node); | ||||
| 	// 	if (succ) | ||||
| 	// 	{ | ||||
| 	// 		var obj = JSON.parse(info); | ||||
| 	// 		var s = ""; | ||||
| 	// 		for (var i in obj) | ||||
| 	// 			s += i + ": " + obj[i] + "\n"; | ||||
| 	// 		cx.alert(s); | ||||
| 	// 	} | ||||
| 	// 	else | ||||
| 	// 		cx.alert("location failure: " + info); | ||||
| 	// } | ||||
| } | ||||
|  | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/home.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/home.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "5be63ed4-375a-425e-baa1-f1a369d91bfd", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
							
								
								
									
										45
									
								
								cx3-demo/assets/script/page/pageBanner.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								cx3-demo/assets/script/page/pageBanner.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| import {_decorator, Component, Node, PageView, UITransform} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('pageBanner') | ||||
| class pageBanner extends Component  | ||||
| { | ||||
|     data: any; | ||||
|  | ||||
|     start ()  | ||||
|     { | ||||
|         cx.gn(this, "spClose").setTouchCallback(this, cx.closePage); | ||||
|  | ||||
|         this.scheduleOnce(this.loadBanner, 0.5); | ||||
|  | ||||
|         cx.script.pageView.initAutoScroll(this, "viewBanner", 2, true, this.onBannerClick); //自动循环滚动 | ||||
|     } | ||||
|  | ||||
|     loadBanner () | ||||
|     { | ||||
|         var data = [ | ||||
|             {id:1, img: "banner1"}, | ||||
|             {id:2, img: "banner2"}, | ||||
|             {id:3, img: "banner3"} | ||||
|         ]; | ||||
|  | ||||
|         var pageView: PageView = cx.gn(this, "viewBanner").getComponent(PageView)!; | ||||
|         pageView.removeAllPages(); | ||||
|         for (var i in data) | ||||
|         { | ||||
|             var node: Node = new Node(); | ||||
|             node.pro().dataIndex = i; | ||||
|             node.addComponent(UITransform).setContentSize(pageView.node.getContentSize()); | ||||
|             pageView.addPage(node); | ||||
|             cx.res.setImageFromRes(node, data[i].img); | ||||
|         } | ||||
|  | ||||
|         this.data = data; | ||||
|     } | ||||
|  | ||||
|     onBannerClick (page: Node) | ||||
|     { | ||||
|         cx.hint("banner id: " + this.data[page.pro().dataIndex].id); | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/pageBanner.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/pageBanner.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "b8721887-5481-415b-9f31-719ecd12703b", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
							
								
								
									
										25
									
								
								cx3-demo/assets/script/page/pageChild.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								cx3-demo/assets/script/page/pageChild.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| import {_decorator, Component} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('pageChild') | ||||
| class PageChild extends Component  | ||||
| { | ||||
| 	start ()  | ||||
| 	{ | ||||
|         // 关闭页面的两种方式: | ||||
|         cx.gn(this, "spClose").setTouchCallback(this, cx.closePage); | ||||
| 		cx.gn(this, "spClosePage").setTouchCallback(this, this.close); | ||||
|  | ||||
|         cx.gn(this, "spAlert").setTouchCallback(this, () => { cx.alert("pageChild alert"); }); | ||||
|  | ||||
|         //cx.showPage可以直接放在setTouchCallback里 | ||||
|         cx.gn(this, "spShowPage").setTouchCallback(this, cx.showPage, "ui/pageChild"); | ||||
|     } | ||||
|  | ||||
|     close () | ||||
|     { | ||||
|         //do something | ||||
|         cx.closePage(this); | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/pageChild.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/pageChild.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "64ed96d0-f2c5-41de-a2d1-d64c0313d5c0", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
							
								
								
									
										39
									
								
								cx3-demo/assets/script/page/pagePicker.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								cx3-demo/assets/script/page/pagePicker.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import {_decorator, Component, Node, Label} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('pagePicker') | ||||
| class PagePicker extends Component  | ||||
| { | ||||
|     start ()  | ||||
|     { | ||||
|         cx.gn(this, "spClose").setTouchCallback(this, cx.closePage); | ||||
|         cx.gn(this, "spYearMonth").setTouchCallback(this, this.showPicker); | ||||
|         cx.gn(this, "spMonthDay").setTouchCallback(this, this.showPicker); | ||||
|         cx.gn(this, "spYearMonthDay").setTouchCallback(this, this.showPicker); | ||||
|         cx.gn(this, "spHourMinute").setTouchCallback(this, this.showPicker); | ||||
|         cx.gn(this, "spString").setTouchCallback(this, this.showPicker); | ||||
|         cx.gn(this, "spObject").setTouchCallback(this, this.showPicker); | ||||
|     } | ||||
|  | ||||
|     showPicker (sender: Node) | ||||
|     { | ||||
|         switch (sender.name) | ||||
|         { | ||||
|             case "spYearMonth": cx.picker.createYearMonth(this, this.pickerCallback, cx.picker.year(-1, 1)); break; | ||||
|             case "spMonthDay": cx.picker.createMonthDay(this, this.pickerCallback, cx.picker.month(1), 2, null, 28); break; | ||||
|             case "spYearMonthDay": cx.picker.createYearMonthDay(this, this.pickerCallback, cx.picker.year(-3, 0)); break; | ||||
|             case "spHourMinute": cx.picker.createHourMinute(this, this.pickerCallback); break; | ||||
|             case "spString": cx.picker.create(this, this.pickerCallback, [{data:["A", "B"], index:1}]); break; | ||||
|             case "spObject": cx.picker.create(this, this.pickerCallback, [{data:[{id:1, name:"A"}, {id:2, name:"B"}], display:"name", index:1}]); break; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pickerCallback () | ||||
|     { | ||||
|         var s = "\n"; | ||||
|         for (var i in arguments) | ||||
|             s += JSON.stringify(arguments[i]) + "\n"; | ||||
|         cx.gn(this, "lblSelected").getComponent(Label)!.string = s; | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/pagePicker.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/pagePicker.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "d2e4ba14-2bbd-4fa8-8bbb-7afebacf7520", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
							
								
								
									
										63
									
								
								cx3-demo/assets/script/page/pageScrollView.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								cx3-demo/assets/script/page/pageScrollView.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | ||||
| import {_decorator, Component, Node, Label, color} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('pageScrollView') | ||||
| class pageScrollView extends Component  | ||||
| { | ||||
|     dataCount: number = 0; | ||||
|     isRefresh: boolean = false; | ||||
|  | ||||
| 	start ()  | ||||
|     { | ||||
|         cx.gn(this, "spClose").setTouchCallback(this, cx.closePage); | ||||
|  | ||||
|         cx.script.scrollView.initDeltaInsert(this, "view", this.queryData);   //设置增量新增数据到view的能力 | ||||
|         cx.script.scrollView.initDropRefresh(this, "view", this.refreshData); //设置下拉刷新能力 | ||||
|  | ||||
|         this.queryData(); | ||||
|     } | ||||
|  | ||||
|     refreshData () | ||||
|     { | ||||
|         this.dataCount = 0; | ||||
|         this.isRefresh = true; | ||||
|         this.queryData(); | ||||
|     } | ||||
|  | ||||
|     queryData () | ||||
|     { | ||||
|         //模拟从服务器取数据,0.5秒后获得数据 | ||||
|         cx.log("queryData " + this.dataCount); | ||||
|         this.scheduleOnce(this.queryDataOk, 0.5); | ||||
|     } | ||||
|  | ||||
|     queryDataOk () | ||||
|     { | ||||
|         cx.log("queryDataOk..."); | ||||
|         if (this.isRefresh) | ||||
|         { | ||||
|             this.isRefresh = false; | ||||
|             cx.gn(this, "content").removeAllChildren(); | ||||
|         } | ||||
|  | ||||
|         for (var i = 0; i < 20; i++) | ||||
|             this.createPanel(); | ||||
|  | ||||
|         cx.script.scrollView.overDeltaInsert(this, this.dataCount > 200);  //结束新增能力,模拟总数量200个 | ||||
|         cx.script.scrollView.overDropRefresh(this);                        //结束本次下拉刷新 | ||||
|     } | ||||
|  | ||||
|  | ||||
|     createPanel () | ||||
|     { | ||||
|         var node = new Node(); | ||||
|         node.addComponent(Label).string = ++this.dataCount + ""; | ||||
|         node.getComponent(Label)!.color = color("555555"); | ||||
|  | ||||
|         var panel = cx.createPanel("ffffffff", cx.sw, 100); | ||||
|         panel.addChild(node); | ||||
|  | ||||
|         cx.gn(this, "content").addChild(panel); | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/pageScrollView.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/pageScrollView.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "4a8b8222-d7ed-44bb-ab1d-115087a9c42a", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
							
								
								
									
										105
									
								
								cx3-demo/assets/script/page/pageVideo.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								cx3-demo/assets/script/page/pageVideo.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| import {_decorator, Node, Component, Label} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('pageVideo') | ||||
| class PageVideo extends Component  | ||||
| { | ||||
|     maskName?: string; | ||||
| 	videoName?: string; | ||||
|     videoNodeList!: any[]; | ||||
|  | ||||
| 	start ()  | ||||
| 	{ | ||||
| 		cx.gn(this, "spClose").setTouchCallback(this, cx.closePage); | ||||
| 		cx.gn(this, "spShowPage").setTouchCallback(this, this.showPage); | ||||
| 		cx.gn(this, "spAlert").setTouchCallback(this, this.alert); | ||||
|  | ||||
|         if (!cx.os.ios && !cx.os.android) | ||||
|         { | ||||
|             cx.gn(this, "lblVideo").getComponent(Label)!.string = "please run on iOS or android."; | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| 		cx.gn(this, "nodeVideo").setTouchCallback(this, this.setVideoFullScreen); | ||||
|  | ||||
|         //创建一个mask遮罩(扣除标题栏的全屏区域) | ||||
|         var titleSize = cx.gn(this, "layerTitle").getContentSize(); | ||||
|         this.maskName = cx.script.nativeMask.init(this, undefined, 0, cx.sh-titleSize.height, cx.sw, cx.sh-titleSize.height); | ||||
| 		var node = cx.gn(this, "nodeVideo"); | ||||
| 		var rect = cx.convertToDeviceSize(node, 0, 0, node.getWidth(), node.getHeight()); | ||||
| 		var intf = cx.native.ins("video"); | ||||
|  | ||||
|         //在遮罩中创建一个video | ||||
| 		this.videoName = node.name; | ||||
| 		intf.call("createInMask", [this.videoName, this.maskName, rect.x, rect.y, rect.width, rect.height]); | ||||
| 		intf.call("setRoundRadius", [this.videoName, 18]); | ||||
| 		intf.call("play", [this.videoName, "1.mp4"], this.videoCallback.bind(this)); //statics/1.mp4 | ||||
| 		// intf.call("play", [this.videoName, "http://vjs.zencdn.net/v/oceans.mp4"], this.videoCallback.bind(this)); | ||||
| 	    | ||||
| 		// 所有方法 | ||||
| 		// intf.call("create", [this.videoName, rect.x, rect.y, rect.width, rect.height]);  //创建视频 | ||||
| 		// intf.call("createInMask", [this.videoName, maskName, rect.x, rect.y, rect.width, rect.height]);  //在遮罩中创建视频 | ||||
| 		// intf.call("setRoundRadius", [this.videoName, radius]);  //设置圆角遮罩 | ||||
| 		// intf.call("play", [this.videoName, url, callback]);//播放 | ||||
| 		// intf.call("pause", [this.videoName, true]);        //暂停播放并隐藏 | ||||
| 		// intf.call("resume", [this.videoName]);             //继续播放 | ||||
| 		// intf.call("removeVideo", [this.videoName]);        //关闭并移除 | ||||
| 		// intf.call("removeInMask", [maskName]);             //关闭所有mask中的video | ||||
| 		// intf.call("seekToTime", [this.videoName, 0]);      //跳到x秒处,默认值 0 | ||||
| 		// intf.call("lockSeek", [this.videoName, true]);     //禁止拉动进度条,默认值 false | ||||
| 		// intf.call("showBar", [this.videoName, true]);      //显示控制栏,默认值 false | ||||
| 		// intf.call("setFullScreen", [this.videoName, true]);//全屏播放,默认值 false | ||||
| 		// intf.call("setPosition", [this.videoName, x, y]);  //设置位置 | ||||
| 		 | ||||
| 		this.videoNodeList = this.videoNodeList || []; | ||||
| 		this.videoNodeList.push(node); | ||||
| 	} | ||||
|  | ||||
| 	showPage () | ||||
| 	{ | ||||
| 		this.videoName && cx.native.ins("video").call("pause", [this.videoName, !!cx.os.android]); | ||||
| 		cx.showPage("ui/pageChild"); | ||||
| 	}  | ||||
|  | ||||
| 	alert () | ||||
| 	{ | ||||
| 		cx.alert("这是一个显示在原生视频层之上效果的cocos界面(android暂未实现)"); | ||||
| 	}  | ||||
|  | ||||
| 	setVideoFullScreen (sender: Node) | ||||
| 	{ | ||||
| 		cx.native.ins("video").call("setFullScreen", [sender.name, true]); | ||||
| 	} | ||||
|  | ||||
| 	videoCallback (state: number, value: string) | ||||
| 	{ | ||||
| 		cx.log("video state:" + state + ", value: " + value); | ||||
| 		cx.gn(this, "lblVideo")!.getComponent(Label)!.string = "state:" + state + " value: " + value; | ||||
| 	} | ||||
|  | ||||
| 	update () | ||||
| 	{ | ||||
| 		for (var i in this.videoNodeList) | ||||
| 		{ | ||||
| 			var node = this.videoNodeList[i]; | ||||
| 			var leftTop = cx.convertToDeviceSize(node, 0, 0); | ||||
| 			if (node.priorX != Math.round(leftTop.x) || node.priorY != Math.round(leftTop.y)) | ||||
| 			{ | ||||
| 				node.priorX = Math.round(leftTop.x); | ||||
| 				node.priorY = Math.round(leftTop.y); | ||||
| 				cx.native.ins("video").call("setPosition", [this.videoName, leftTop.x, leftTop.y]); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	onChildPageClosed(childPage: any) | ||||
| 	{ | ||||
| 		this.videoName && cx.native.ins("video").call("resume", [this.videoName]); | ||||
| 	} | ||||
|  | ||||
| 	onDestroy () | ||||
| 	{ | ||||
| 		this.maskName && cx.native.ins("video").call("removeInMask", [this.maskName]); | ||||
| 	} | ||||
| } | ||||
|  | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/pageVideo.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/pageVideo.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "25316e67-d064-4a6d-9233-a5e08407e7f9", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
							
								
								
									
										49
									
								
								cx3-demo/assets/script/page/start.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								cx3-demo/assets/script/page/start.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| import {_decorator, Component, Node, color, Label} from 'cc'; | ||||
| const {ccclass} = _decorator; | ||||
|  | ||||
| @ccclass('start') | ||||
| class Start extends Component  | ||||
| { | ||||
| 	tabs!: any[]; | ||||
| 	onLoad ()  | ||||
| 	{ | ||||
| 		console.log("Start onLoad..."); | ||||
|  | ||||
| 		this.node.slideEventDisabled = true; | ||||
| 		this.node.pageActionDisabled = true; | ||||
| 		this.node.androidBackHandler = "closeApp"; | ||||
|  | ||||
| 		this.tabs = [ | ||||
| 			{name: "ui/home"}, | ||||
| 			{name: "ui/mine"} | ||||
| 		]; | ||||
|  | ||||
| 		cx.gn(this, "tabHome").setTouchCallback(this, this.showTab, 0); | ||||
| 		cx.gn(this, "tabMine").setTouchCallback(this, this.showTab, 1); | ||||
|  | ||||
| 		this.showTab(undefined, 0); | ||||
| 	} | ||||
|  | ||||
| 	showTab (sender: any, index: any) | ||||
| 	{ | ||||
| 		for (var i in this.tabs) | ||||
| 		{ | ||||
| 			var tab: any = this.tabs[i]; | ||||
| 			if (tab.page) | ||||
| 				tab.page.active = i == index; | ||||
| 			else if (i == index) | ||||
| 			{ | ||||
| 				tab.page = {}; | ||||
| 				cx.addPage(cx.gn(this, "layerPage"), tab.name, undefined, (page:Node) => { this.tabs[index].page = page; }); | ||||
| 			} | ||||
| 		} | ||||
| 		var children = cx.gn(this, "layerTab").children; | ||||
| 		for (var i in children) | ||||
| 		{ | ||||
| 			var child:Node = children[i]; | ||||
| 			child.getChildByName("img")!.active = i == index; | ||||
| 			child.getChildByName("imgGray")!.active = i != index; | ||||
| 			child.getChildByName("label")!.getComponent(Label)!.color = color(i == index ? "22A1FF" : "777777"); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										9
									
								
								cx3-demo/assets/script/page/start.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								cx3-demo/assets/script/page/start.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   "ver": "4.0.22", | ||||
|   "importer": "typescript", | ||||
|   "imported": true, | ||||
|   "uuid": "dd9c6400-5e86-497a-a04b-226cafc786c2", | ||||
|   "files": [], | ||||
|   "subMetas": {}, | ||||
|   "userData": {} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user