zoukankan      html  css  js  c++  java
  • quick cocos touch 2

    local scheduler = require(cc.PACKAGE_NAME .. ".scheduler")
    
    local MainScene = class("MainScene", function()
        return display.newScene("MainScene")
    end)
    
    function MainScene:ctor()
        
        -- p
        self.time_=3
        self.isAdd_="noAdd"
    
        --listerner
        local layer = display.newLayer():addTo(self)
        layer:setTouchEnabled(true)
        layer:setTouchMode(cc.TOUCH_MODE_ONE_BY_ONE)
        layer:addNodeEventListener(cc.NODE_TOUCH_EVENT, function (event)
            local x, y, prevX, prevY = event.x, event.y, event.prevX, event.prevY
    
            if event.name == "began" then
                print("layer began")
                if(self.isAdd_=="noAdd") then
                    self.time_=3
                    self:addP()
                end
            elseif event.name == "moved" then
                print("layer moved")
            elseif event.name == "ended" then
                
                print("layer ended")
            end
    
            return true
        end)
        
    end
    
    function MainScene:addP()
        print("add")
        self.handle=scheduler.scheduleGlobal(function()
            self:p()   
        end ,1/60)
    end
    
    function MainScene:p()
        
        print("time:" .. self.time_)
        print( self.isAdd_)
        self.isAdd_="added"
        self.time_=self.time_-0.1
        if self.time_<0 then
            self.isAdd_="noAdd"
            scheduler.unscheduleGlobal(self.handle)
        end
        
        
    end
    
    
    
    
    
    return MainScene
  • 相关阅读:
    百度地图API示例之小实践 添加代理商标注
    MySQL分组操作
    MySQL连表操作
    MySQL多对多操作
    MySQL一对一操作
    MySQL唯一索引
    MySQL用户授权管理
    MySQL外键操作
    MySQL删操作
    MySQL增操作
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4318086.html
Copyright © 2011-2022 走看看