zoukankan      html  css  js  c++  java
  • quick cocos animate manage

    local scheduler = require(cc.PACKAGE_NAME .. ".scheduler")
    
    local MainScene = class("MainScene", function()
        return display.newScene("MainScene")
    end)
    
    function MainScene:ctor()
       
        
        display.addSpriteFrames("bandit.plist","bandit.png")
        self.hero_=display.newSprite("#player_idle1.png",display.cx,display.cy):addTo(self)
        self.status="play"    
        
        self.isPlay="no"
        
        scheduler.scheduleUpdateGlobal(function() 
            if self.status=="play"   then 
                if self.isPlay~="playing" then
                    local frames = display.newFrames("player_run%1d.png", 1, 6)
                    local animation = display.newAnimation(frames, 0.1)
                    local animate=cc.Animate:create(animation)
                    self.repeatAnimate=cc.RepeatForever:create(animate)
                    self.hero_:runAction(self.repeatAnimate)
                    self.isPlay="playing"
                end
                
            else
                self.hero_:stopAction(self.repeatAnimate)
                self.isPlay="no"
            end
             
        end ) 
        
        
        
        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
            elseif event.name == "moved" then
            elseif event.name == "ended" then
                if self.status=="play" then 
                    self.status="stop"            
                else
                    self.status="play"
                end
            end
    
            return true
        end)
        
        
        
    end
    
    
    
    
    return MainScene
  • 相关阅读:
    php判断是不是https的方法
    [Redis] Redis哨兵模式部署
    Transformer详解:各个特征维度分析推导
    Hell World:)
    cesiumjs
    UVA-11090 Going in Cycle!!
    判断两个数组是否相似 (arraysSimilar)
    Markdown 语法说明 (简体中文版)
    DjangoModels
    Lua 学习 chapter30 编写c函数的技巧
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4320189.html
Copyright © 2011-2022 走看看