zoukankan      html  css  js  c++  java
  • lua -- 商店控制器部分

    -- 创建商店类,继承了Behavior 
    local UIShopController = class("UIShopController", Behavior);
    -- 包含并引用系统提示框
    local SystemPrompt = require(__APP_PACKAGE_NAME__ .. ".scenes.common.SystemPrompt")
    -- 包含引用其他界面
    local UIGoodsInfoController = require(__APP_PACKAGE_NAME__ .. ".scenes.mainScene.uiShop.UIGoodsInfoController");
    
    -- 相当于构造函数
    function UIShopController:ctor( )
        -- 调用父类的构造函数 
        UIShopController.super.ctor(self);
        -- 定义一些成员变量
        self.Name = "UIShopController"
        self.numPerLine = 3
        self.gridXInterval = 165
        self.gridYInterval = 180    
        self.scheduleId = nil
        self.initCDTime = 0
        self.gFlag = 0
        self.selectImageViewItem = nil
        self.lebRefreshTime = nil;
        self.tabMGray = {};
    end
    
    function UIShopController:onAwake( )
        -- 这里初始化部件
        self:initWidget();
    end
    
    function UIShopController:onEnter( )
        SceneM.createNetLayer();
        -- 注册事件消息
        self.owner:registerGlobalEvent(MsgID.msgid_P_OPSHOP_ACK, function ( params )
        
            SceneM.destroyNetLayer();
    
            self:showData();
            
            self.owner:unRegisterGlobalEvent(MsgID.msgid_P_OPSHOP_ACK, self.id);
        end, self.id);
        -- 这里向服务器发送消息,msgid_P_OPSHOP_REQ这是个宏定义,后缀REQ表示请求,
        -- 服务器返回回来的消息是ACK,msgid_P_OPSHOP_ACK,这里也通过这个ACK来注册事件消息
        local msg = {Ext = 0};
        NetController:sendMsg(MsgID.msgid_P_OPSHOP_REQ,CJson.encode(msg));    
    end
    
    -- 这里在退出界面的时候会调用,释放一些资源
    function UIShopController:onExit( )
        if self.selectMask ~= nil then
            self.selectMask:release()
        end
        -- 卸载事件
        self.owner:unRegisterGlobalEvent("onBuy", self.id);
        if self.scheduleId ~= nil then
            -- 卸载定时器
            CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry(self.scheduleId);
        end
    end
  • 相关阅读:
    HTML DOM item() 方法
    php输出年份
    CSS中如何选择ul下li的奇数、偶数行
    对象的继承
    this指向
    如何安装Firebug
    JSON数据格式
    PHP: configure: error: mysql configure failed. Please check config.log for more information.
    linux下挂载iso镜像文件(转)
    Linux 下mysql修改数据库存放目录方法和可能遇到的问题
  • 原文地址:https://www.cnblogs.com/newlist/p/3667198.html
Copyright © 2011-2022 走看看