[ create a new paste ] login | about

Link: http://codepad.org/gYufliIO    [ raw code | fork ]

Lua, pasted on Jan 26:
ClipFont=class("ClipFont",function()
    return cc.ClippingNode:create()
end)

ClipFont.init=function(self)
    self:setInverted(false)
    self:setAlphaThreshold(0.5)
    local size=cc.Director:getInstance():getWinSize()

    local loadTitle=function()
        local title=cc.Sprite:create()
        title:setTexture("clipfont/game_title.png")
        title:setPosition(size.width/2,size.height/2)
        return title
    end

    local loadSpark=function()
        local spark=cc.Sprite:create()
        spark:setTexture("clipfont/spark.png")
        spark:setAnchorPoint(1,1)
        spark:setPosition(0,size.height)
        local move_end=cc.MoveTo:create(1,cc.p(size.width,size.height))
        local move_begin=cc.MoveTo:create(1,cc.p(0,size.height))
        local seq=cc.Sequence:create(move_end,move_begin)
        spark:runAction(cc.RepeatForever:create(seq))
        return spark
    end

    local title=loadTitle()
    local spark=loadSpark()
    self:addChild(title,1)
    self:addChild(spark,2)
    self:setStencil(title)
end

ClipFont.create=function(self)
    local node=ClipFont.new()
    node:init()
    return node
end

return ClipFont


Create a new paste based on this one


Comments: