码迷,mamicode.com
首页 > 其他好文 > 详细

quick cocos animate manage

时间:2015-03-07 14:02:55      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

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

 

quick cocos animate manage

标签:

原文地址:http://www.cnblogs.com/yufenghou/p/4320189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!