update
This commit is contained in:
@@ -61,7 +61,7 @@ export class GButton {
|
||||
}
|
||||
//点击音效处理
|
||||
if (buttonType > 0) {
|
||||
AudioManager.I.PlayEffect(buttonType); //音效
|
||||
//AudioManager.I.PlayEffect(buttonType); //音效
|
||||
}
|
||||
}, obj);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,16 @@ export default class GameRootUI extends Component {
|
||||
@property
|
||||
public DefaultUI: string = "" //默认打开的界面
|
||||
|
||||
private defaultView:Node;
|
||||
|
||||
showDefaultView()
|
||||
{
|
||||
this.defaultView.active =true;
|
||||
}
|
||||
hideDefaultView():void{
|
||||
this.defaultView.active = false;
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
GameRootUI.I = this;
|
||||
}
|
||||
@@ -53,6 +63,7 @@ export default class GameRootUI extends Component {
|
||||
if (this.DefaultUI.length > 0) {
|
||||
ResManager.I.loadSubpackagePrefab(this.DefaultUI, (res)=>{
|
||||
|
||||
this.defaultView = res;
|
||||
let viewSP = res.getComponent(res.name);
|
||||
viewSP && viewSP.openUIData && viewSP.openUIData(null);
|
||||
|
||||
|
||||
@@ -148,7 +148,25 @@ export default class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**适配背景图
|
||||
* @method node 背景图节点
|
||||
* @param mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
*/
|
||||
public static adjustBgPixelRatioToSize(windowSize:Size,node:Node, mod:number = 1) {
|
||||
//let windowSize = view.getVisibleSize();
|
||||
let bgTf = node.getComponent(UITransform)
|
||||
if (bgTf) {
|
||||
if (mod == 1 && bgTf.height < windowSize.height) {
|
||||
let scale = windowSize.height / bgTf.height
|
||||
bgTf.height = bgTf.height * scale
|
||||
bgTf.width = bgTf.width * scale
|
||||
} else if (mod == 2 && bgTf.width < windowSize.width) {
|
||||
let scale = windowSize.width / bgTf.width
|
||||
bgTf.height = bgTf.height * scale
|
||||
bgTf.width = bgTf.width * scale
|
||||
}
|
||||
}
|
||||
}
|
||||
/**适配背景图
|
||||
* @method node 背景图节点
|
||||
* @param mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
@@ -157,6 +175,15 @@ export default class Utils {
|
||||
let windowSize = view.getVisibleSize();
|
||||
let bgTf = node.getComponent(UITransform)
|
||||
if (bgTf) {
|
||||
if(mod == 3)
|
||||
{
|
||||
if(windowSize.height-bgTf.height < windowSize.width-bgTf.width )
|
||||
{
|
||||
mod = 1;
|
||||
}else{
|
||||
mod = 2;
|
||||
}
|
||||
}
|
||||
if (mod == 1 && bgTf.height < windowSize.height) {
|
||||
let scale = windowSize.height / bgTf.height
|
||||
bgTf.height = bgTf.height * scale
|
||||
|
||||
@@ -22,4 +22,7 @@ export enum InnerMsgCode {
|
||||
|
||||
BgVideo_Ready, //背景视频准备完成
|
||||
BgVideo_End, //背景视频播放完毕
|
||||
|
||||
|
||||
Chat_DialogRefresh
|
||||
}
|
||||
@@ -100,7 +100,7 @@ export default class ResManager {
|
||||
}
|
||||
/** 加载bundle中的PB*/
|
||||
loadSubpackagePrefab(url: string, cb) {
|
||||
let bundle = assetManager.getBundle("PB");
|
||||
let bundle = assetManager.getBundle("Chat18x");
|
||||
if (bundle){
|
||||
bundle.load(url, Prefab, (err, res: Prefab) => {
|
||||
if (err) {
|
||||
|
||||
@@ -19,7 +19,7 @@ export class MainScene extends Component {
|
||||
let gameRootUI = this.node.getComponent(GameRootUI)
|
||||
if (!gameRootUI){
|
||||
gameRootUI = this.node.addComponent(GameRootUI)
|
||||
gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "UI/StartUI/Start_UI");
|
||||
gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "GirlListPanel");
|
||||
}
|
||||
GameRootUI.MainCamera = this.MainCamera
|
||||
}
|
||||
|
||||
@@ -20,22 +20,22 @@ export class PreloadUI extends Component {
|
||||
private jinduBar: Node = null;
|
||||
private jinduFilled: Sprite = null;
|
||||
private LabProgress: Label = null;
|
||||
private btnLogin: Sprite = null; //登录按钮
|
||||
//private btnLogin: Sprite = null; //登录按钮
|
||||
|
||||
start() {
|
||||
Utils.addInnerEL(InnerMsgCode.UI_ShowPrompt, this, this.resiveShowPrompt)
|
||||
//Utils.addInnerEL(InnerMsgCode.UI_ShowPrompt, this, this.resiveShowPrompt)
|
||||
|
||||
this.jinduBar = this.node.getChildByName("jinduBar");
|
||||
this.jinduFilled = this.jinduBar.getChildByName("jinduFilled").getComponent(Sprite);
|
||||
this.LabProgress = this.node.getChildByName("LabProgress").getComponent(Label);
|
||||
this.btnLogin = this.node.getChildByName("btnLogin").getComponent(Sprite);
|
||||
//this.btnLogin = this.node.getChildByName("btnLogin").getComponent(Sprite);
|
||||
|
||||
//适配背景图
|
||||
let BG = this.node.getChildByName("BG");
|
||||
Utils.adjustBgPixelRatio(BG, 1)
|
||||
|
||||
this.jinduFilled.fillRange = 0;
|
||||
this.btnLogin.node.active = false;
|
||||
//this.btnLogin.node.active = false;
|
||||
|
||||
this.preloadFiles()
|
||||
}
|
||||
@@ -68,26 +68,29 @@ export class PreloadUI extends Component {
|
||||
//预加载文件
|
||||
preloadFiles() {
|
||||
let preloadTab = [
|
||||
{path:"Music/music_interface", bundleName: "Audio", ftype: AudioClip},
|
||||
{path:"bg/mengli_stage_bg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg0/mengli_0_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg1/mengli_1_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg2/mengli_2_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"cg3/mengli_3_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"emo_1/mengli_shy", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"emo_2/mengli_laugh", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"emo_3/mengli_disgust", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"role/mengli_default", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"Zjm/raw1", bundleName: "Raw", ftype: ImageAsset},
|
||||
{path:"touming", bundleName: "common", ftype: ImageAsset},
|
||||
// {path:"chanpin_1_0", bundleName: "daoju", ftype: ImageAsset}, //有合图加载失败
|
||||
{path:"zjm_1", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
{path:"zjm_19", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
{path:"zjm_30", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
{path:"mohu", bundleName: "Materials", ftype: Material},
|
||||
{path:"UI/Cross/Cross_UI", bundleName: "PB", ftype: Prefab},
|
||||
{path:"UI/StartUI/Start_UI", bundleName: "PB", ftype: Prefab},
|
||||
{path:"commonGlobal", bundleName: "DataTable", ftype: JsonAsset},
|
||||
{path:"ChatPanel", bundleName: "Chat18x", ftype: Prefab},
|
||||
{path:"GirlDetailPanel", bundleName: "Chat18x", ftype: Prefab},
|
||||
{path:"GirlListPanel", bundleName: "Chat18x", ftype: Prefab},
|
||||
// {path:"Music/music_interface", bundleName: "Audio", ftype: AudioClip},
|
||||
// {path:"bg/mengli_stage_bg", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"cg0/mengli_0_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"cg1/mengli_1_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"cg2/mengli_2_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"cg3/mengli_3_cg", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"emo_1/mengli_shy", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"emo_2/mengli_laugh", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"emo_3/mengli_disgust", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"role/mengli_default", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"Zjm/raw1", bundleName: "Raw", ftype: ImageAsset},
|
||||
// {path:"touming", bundleName: "common", ftype: ImageAsset},
|
||||
// // {path:"chanpin_1_0", bundleName: "daoju", ftype: ImageAsset}, //有合图加载失败
|
||||
// {path:"zjm_1", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
// {path:"zjm_19", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
// {path:"zjm_30", bundleName: "Zhujiemian", ftype: ImageAsset},
|
||||
// {path:"mohu", bundleName: "Materials", ftype: Material},
|
||||
// {path:"UI/Cross/Cross_UI", bundleName: "PB", ftype: Prefab},
|
||||
// {path:"UI/StartUI/Start_UI", bundleName: "PB", ftype: Prefab},
|
||||
// {path:"commonGlobal", bundleName: "DataTable", ftype: JsonAsset},
|
||||
];
|
||||
let num_prefab = 0; //已加载数量
|
||||
let num_succeed = 0;//加载成功数量
|
||||
@@ -117,10 +120,10 @@ export class PreloadUI extends Component {
|
||||
//加载配置表
|
||||
loadDataTable(){
|
||||
let dataArr = [
|
||||
"commonGlobal",
|
||||
//"commonGlobal",
|
||||
// "levelHole",
|
||||
"Music",
|
||||
"Sound",
|
||||
//"Music",
|
||||
//"Sound",
|
||||
]
|
||||
|
||||
//配置表使用方法: let cfgs = Resource.getConfig("Sound")
|
||||
@@ -149,57 +152,58 @@ export class PreloadUI extends Component {
|
||||
//登录
|
||||
onLogin() {
|
||||
//初始化SDK信息
|
||||
SDKManager.init(() => {
|
||||
//检测是否有授权,有授权直接登录,没有授权就先进主界面,到主界面获取权限
|
||||
SDKManager.checkAutoSetting("userInfo", (ishave) => {
|
||||
if (ishave) {
|
||||
console.log("有授权,直接登录")
|
||||
HttpUnit.ins.login((loginData) => {
|
||||
if (loginData == null) {
|
||||
//登录失败,这里处理重复登录的逻辑
|
||||
} else {
|
||||
this.loginFinish = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log("没有授权,等待授权后登录")
|
||||
// this.loginFinish = true
|
||||
this.jinduBar.active = false
|
||||
this.LabProgress.node.active = false
|
||||
//登录按钮
|
||||
this.btnLogin.node.active = true
|
||||
let loginPath = ""
|
||||
if (SDKManager.isWenxin()) {
|
||||
loginPath = "login1"
|
||||
} else if (SDKManager.isByteDance()) {
|
||||
loginPath = "login2"
|
||||
} else if (SDKManager.isKuaishou()) {
|
||||
loginPath = "login3"
|
||||
}
|
||||
ResManager.I.changeResourceSpriteFrame(this.btnLogin, loginPath)
|
||||
|
||||
HttpUnit.ins.login((loginData) => {
|
||||
if (loginData == null) {
|
||||
//登录失败,这里处理重复登录的逻辑
|
||||
} else {
|
||||
this.loginFinish = true
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
// SDKManager.init(() => {
|
||||
// //检测是否有授权,有授权直接登录,没有授权就先进主界面,到主界面获取权限
|
||||
// SDKManager.checkAutoSetting("userInfo", (ishave) => {
|
||||
// if (ishave) {
|
||||
// console.log("有授权,直接登录")
|
||||
// HttpUnit.ins.login((loginData) => {
|
||||
// if (loginData == null) {
|
||||
// //登录失败,这里处理重复登录的逻辑
|
||||
// } else {
|
||||
// this.loginFinish = true
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// console.log("没有授权,等待授权后登录")
|
||||
// // this.loginFinish = true
|
||||
// this.jinduBar.active = false
|
||||
// this.LabProgress.node.active = false
|
||||
// //登录按钮
|
||||
// this.btnLogin.node.active = true
|
||||
// let loginPath = ""
|
||||
// if (SDKManager.isWenxin()) {
|
||||
// loginPath = "login1"
|
||||
// } else if (SDKManager.isByteDance()) {
|
||||
// loginPath = "login2"
|
||||
// } else if (SDKManager.isKuaishou()) {
|
||||
// loginPath = "login3"
|
||||
// }
|
||||
// ResManager.I.changeResourceSpriteFrame(this.btnLogin, loginPath)
|
||||
//
|
||||
// HttpUnit.ins.login((loginData) => {
|
||||
// if (loginData == null) {
|
||||
// //登录失败,这里处理重复登录的逻辑
|
||||
// } else {
|
||||
// this.loginFinish = true
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
this.loginFinish = true;
|
||||
}
|
||||
|
||||
enterGame() {
|
||||
let islogin = HttpUnit.IsLogin();
|
||||
console.log("进入游戏,登录状态:", islogin);
|
||||
//let islogin = HttpUnit.IsLogin();
|
||||
//console.log("进入游戏,登录状态:", islogin);
|
||||
this.jinduBar.active = false
|
||||
this.LabProgress.node.active = false
|
||||
this.btnLogin.node.active = false
|
||||
if (islogin) {
|
||||
} else {
|
||||
//没登录成功,先进主界面,在主界面里进行登录
|
||||
}
|
||||
//this.btnLogin.node.active = false
|
||||
// if (islogin) {
|
||||
// } else {
|
||||
// //没登录成功,先进主界面,在主界面里进行登录
|
||||
// }
|
||||
ResManager.I.goMainScene(); //进入下一个场景
|
||||
// ResManager.I.goCustomScene("Test2DScene"); //进入自定义场景
|
||||
}
|
||||
|
||||
@@ -2,10 +2,17 @@ import { _decorator, Component, EditBox, Node,Label } from "cc";
|
||||
import { DemoManager } from "./DemoManager";
|
||||
import { ChatGPTService } from "./ChatGPTService";
|
||||
import {characters} from "db://assets/Scripts/test/cfg/characters";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {InnerMsgCode} from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
import {ChatContentsLayout} from "db://assets/Scripts/test/ChatContentsLayout";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import GameRootUI from "db://assets/Scripts/Main/Common/GameRootUI";
|
||||
import {ImagePopup} from "db://assets/Scripts/test/ImagePopup";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("ChatPanel")
|
||||
export class ChatPanel extends Component {
|
||||
export class ChatPanel extends li_BaseView {
|
||||
manager: DemoManager = null;
|
||||
|
||||
@property(EditBox)
|
||||
@@ -14,15 +21,35 @@ export class ChatPanel extends Component {
|
||||
@property(Label)
|
||||
girlName: Label = null;
|
||||
|
||||
@property(ChatContentsLayout)
|
||||
layout: ChatContentsLayout = null;
|
||||
|
||||
@property(ImagePopup)
|
||||
popUpImage: ImagePopup = null;
|
||||
|
||||
id:number
|
||||
|
||||
onLoadCT()
|
||||
{
|
||||
this.register();
|
||||
}
|
||||
register()
|
||||
{
|
||||
Utils.addInnerEL(InnerMsgCode.Chat_DialogRefresh,this,this.onDialogUpdate);
|
||||
}
|
||||
refresh(id:number) {
|
||||
this.id = id;
|
||||
const data = characters[id-1];
|
||||
this.girlName.string = data.name;
|
||||
}
|
||||
|
||||
onDialogUpdate()
|
||||
{
|
||||
this.layout.UpdateDialog(DemoManager.getInstance().getDialogs())
|
||||
}
|
||||
protected onEnable(): void {
|
||||
if (!this.manager) this.manager = DemoManager.getInstance();
|
||||
|
||||
GameRootUI.I.hideDefaultView();
|
||||
}
|
||||
|
||||
public async OnClickSend() {
|
||||
@@ -31,7 +58,8 @@ export class ChatPanel extends Component {
|
||||
console.log("post:" + str);
|
||||
|
||||
this.editBox.string = "";
|
||||
DemoManager.getInstance().updateDialog(true, str);
|
||||
|
||||
DemoManager.getInstance().updateDialog(true, str,true);
|
||||
|
||||
let ret = await ChatGPTService.getInstance().Post({
|
||||
model: "Deepseek-reasoner",
|
||||
@@ -49,5 +77,19 @@ export class ChatPanel extends Component {
|
||||
this.manager.updateDialog(false, rep);
|
||||
}
|
||||
console.log("ret:" + rep);
|
||||
|
||||
//测试
|
||||
this.popUpImage.refresh("Image/1/blur_naked_1");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
returnBtn()
|
||||
{
|
||||
this.onClose();
|
||||
GameRootUI.I.showDefaultView();
|
||||
|
||||
//ViewManager.I.openBundlesView("GirlListPanel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import { DemoData } from "./DemoData";
|
||||
import {GirlDetailPanel} from "db://assets/Scripts/test/GirlDetailPanel";
|
||||
import {ChatPanel} from "db://assets/Scripts/test/ChatPanel";
|
||||
import {GirlListPanel} from "db://assets/Scripts/test/girlListPanel/GirlListPanel";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {InnerMsgCode} from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
|
||||
export class DemoManager {
|
||||
private static _instance: DemoManager;
|
||||
@@ -20,38 +23,26 @@ export class DemoManager {
|
||||
|
||||
demoData: DemoData;
|
||||
|
||||
public layoutout: ChatContentsLayout;
|
||||
public detailPanel:GirlDetailPanel;
|
||||
public chatPanel:ChatPanel;
|
||||
public girlListPanel:GirlListPanel;
|
||||
|
||||
hideMainView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EnterChat(id: number) {
|
||||
if(this.chatPanel==null)
|
||||
{
|
||||
this.chatPanel = find("Canvas/ChatPanel").getComponent(ChatPanel);
|
||||
}
|
||||
this.chatPanel.node.active = true;
|
||||
this.detailPanel.node.active = false;
|
||||
ViewManager.I.openBundlesView("ChatPanel",id);
|
||||
|
||||
}
|
||||
|
||||
EnterDetail(id: number) {
|
||||
if(this.girlListPanel==null)
|
||||
{
|
||||
this.girlListPanel =find("Canvas/GirlListPanel").getComponent(GirlListPanel);
|
||||
}
|
||||
this.girlListPanel.node.active = false;
|
||||
if(this.detailPanel==null)
|
||||
{
|
||||
this.detailPanel = find("Canvas/GirlDetailPanel").getComponent(GirlDetailPanel);
|
||||
}
|
||||
this.detailPanel.refresh(id);
|
||||
this.detailPanel.node.active = true;
|
||||
ViewManager.I.openBundlesView("GirlDetailPanel",id);
|
||||
}
|
||||
|
||||
public updateDialog(isPlayer: boolean, str: string) {
|
||||
public updateDialog(isPlayer: boolean, str: string,fromPlayer:boolean = false) {
|
||||
if(fromPlayer){this.demoData.cleanDialog()}
|
||||
this.demoData.pushDialog(isPlayer, str);
|
||||
console.log("update dialog");
|
||||
this.layoutout.UpdateDialog(this.getDialogs());
|
||||
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
||||
}
|
||||
|
||||
public getDialogs() {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { _decorator, Component, Label, Node, Sprite } from "cc";
|
||||
import { DemoManager } from "./DemoManager";
|
||||
import {Character, characters} from "db://assets/Scripts/test/cfg/characters";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GirlDetailPanel")
|
||||
export class GirlDetailPanel extends Component {
|
||||
export class GirlDetailPanel extends li_BaseView {
|
||||
@property(Sprite)
|
||||
avatar: Sprite;
|
||||
@property(Label)
|
||||
@@ -16,6 +18,12 @@ export class GirlDetailPanel extends Component {
|
||||
chatBtn: Node;
|
||||
id = 0;
|
||||
|
||||
openUIDataCT(data)
|
||||
{
|
||||
this.id = data;
|
||||
this.refresh(this.id);
|
||||
}
|
||||
|
||||
refresh(index:number)
|
||||
{
|
||||
const data = characters[index-1];
|
||||
@@ -25,5 +33,12 @@ export class GirlDetailPanel extends Component {
|
||||
}
|
||||
OnClickChatBtn() {
|
||||
DemoManager.getInstance().EnterChat(this.id);
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
returnBtn()
|
||||
{
|
||||
this.onClose();
|
||||
//ViewManager.I.openBundlesView("GirlListPanel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { _decorator, Component, Node,Sprite,Vec3 ,tween, UITransform} from 'cc';
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ImagePopup')
|
||||
export class ImagePopup extends Component {
|
||||
@property(Sprite)
|
||||
image:Sprite;
|
||||
|
||||
|
||||
start()
|
||||
{
|
||||
this.node.setPosition(new Vec3(-1000,493,0));
|
||||
this.image.node.on(Node.EventType.TOUCH_START,this.openImage);
|
||||
}
|
||||
|
||||
onDestroy()
|
||||
{
|
||||
this.image.node.off(Node.EventType.TOUCH_START,this.openImage);
|
||||
}
|
||||
|
||||
refresh(path:string)
|
||||
{
|
||||
ResManager.I.changeBundleSpriteFrame(this.image,path,"Chat18x",()=>{
|
||||
let sizeTran = this.image.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize,this.image.node,2);
|
||||
this.popUp();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
openImage()
|
||||
{
|
||||
ViewManager.I.openBundlesView('ShowPanel');
|
||||
}
|
||||
popUp()
|
||||
{
|
||||
tween(this.node).to(0.5,{position:new Vec3(-559.374,493,0)},{easing:"backOut"}).start();
|
||||
this.scheduleOnce(()=>{
|
||||
this.popDown();
|
||||
},5);
|
||||
}
|
||||
popDown()
|
||||
{
|
||||
tween(this.node).to(0.5,{position:new Vec3(-1000,493,0)},{easing:"backIn"}).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c0cd7ea3-c521-468b-b49c-6c04142e385d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from "cc";
|
||||
import { DemoManager } from "../DemoManager";
|
||||
import { Character, characters } from "db://assets/Scripts/test/cfg/characters";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GirlListItem")
|
||||
@@ -26,19 +27,17 @@ export class GirlListItem extends Component {
|
||||
|
||||
id: number = -1;
|
||||
|
||||
protected onEnable(): void {
|
||||
this.refreshData(1);
|
||||
}
|
||||
|
||||
refreshData(index: number) {
|
||||
const data = characters[index - 1];
|
||||
baseNode: Node;
|
||||
refreshData(data: Character,base:Node) {
|
||||
this.id = data.id;
|
||||
this.girlName.string = data.name;
|
||||
//this.avatar.spriteFrame =
|
||||
this.baseNode = base;
|
||||
}
|
||||
|
||||
onClickDetail() {
|
||||
DemoManager.getInstance().EnterDetail(this.id);
|
||||
//ViewManager.I.closeView(this.baseNode);
|
||||
}
|
||||
|
||||
update(deltaTime: number) {}
|
||||
|
||||
@@ -1,17 +1,52 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { _decorator, Component, Node,instantiate } from 'cc';
|
||||
import {characters} from "db://assets/Scripts/test/cfg/characters";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {GirlListItem} from "db://assets/Scripts/test/girlListPanel/GirlListItem";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('GirlListPanel')
|
||||
export class GirlListPanel extends Component {
|
||||
onEnable()
|
||||
{
|
||||
const cfg = characters;
|
||||
for (let i = 0; i < cfg.length; i++) {
|
||||
const c = cfg[i];
|
||||
export class GirlListPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
itemInst:GirlListItem;
|
||||
content:Node;
|
||||
|
||||
cache:GirlListItem[] = [];
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node,this._nodeTab);
|
||||
this.registerListener();
|
||||
this.itemInst = this._nodeTab.BubbleItem.getComponent(GirlListItem);
|
||||
this.itemInst.node.active = false;
|
||||
this.content = this._nodeTab.content;
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
||||
show()
|
||||
{
|
||||
if(this.cache)
|
||||
{
|
||||
for(let i = this.cache.length-1; i >=0; i--)
|
||||
{
|
||||
this.cache[i].node.destroy();
|
||||
}
|
||||
}
|
||||
const config = characters;
|
||||
for (let i = 0; i < config.length; i++) {
|
||||
const cfg = config[i];
|
||||
let newNode = instantiate(this.itemInst.node)
|
||||
let item = newNode.getComponent(GirlListItem);
|
||||
item.refreshData(cfg,this.node);
|
||||
newNode.active = true;
|
||||
this.cache.push(item);
|
||||
this.content.addChild(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private registerListener() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { _decorator, Component, Node,Sprite ,UITransform} from 'cc';
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import {GButton} from "db://assets/Scripts/Main/Common/GButton";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ShowPanel')
|
||||
export class ShowPanel extends li_BaseView {
|
||||
@property(Sprite)
|
||||
image:Sprite;
|
||||
@property(Sprite)
|
||||
splash:Sprite;
|
||||
|
||||
onLoadCT() {
|
||||
this.show("Image/1/naked_1");
|
||||
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
//this.splash.node.on(Node.EventType.TOUCH_START,this.onclickback);
|
||||
GButton.BandClick(this.splash.node,()=>{this.close()},this);
|
||||
}
|
||||
|
||||
|
||||
show(path:string)
|
||||
{
|
||||
ResManager.I.changeBundleSpriteFrame(this.image,path,"Chat18x",()=>{
|
||||
Utils.adjustBgPixelRatio(this.image.node,3);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b7645da0-3b81-454b-8956-068491ce4706",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user