首页 > 其他 > 详细

quick cocos animate manage

时间:2015-03-07 14:00:08      阅读:399      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!