Skip to content

Commit

Permalink
CCSUIloader2 support parse "Layer" Object
Browse files Browse the repository at this point in the history
  • Loading branch information
SunLightJuly committed May 23, 2015
1 parent ff4e527 commit bddd398
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion quick/framework/cc/uiloader/CCSUILoader2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ function CCSUILoader:createUINode(clsName, options, parent)
node = self:createPageView(options)
elseif clsName == "ProjectNode" then
node = self:createProjectNode(options)
elseif clsName == "Layer" then
node = self:createLayer(options)
else
printInfo("CCSUILoader not support node:" .. clsName)
end
Expand Down Expand Up @@ -349,6 +351,19 @@ function CCSUILoader:createNode(options)
return node
end

function CCSUILoader:createLayer(options)
local node = cc.Layer:create()
if options.Size then
node:setContentSize(cc.size(options.Size.X or 0, options.Size.Y or 0))
end
node:setPositionX(options.Position.X or 0)
node:setPositionY(options.Position.Y or 0)
node:setAnchorPoint(
cc.p(options.AnchorPoint.ScaleX or 0, options.AnchorPoint.ScaleY or 0))

return node
end

function CCSUILoader:createSprite(options)
local node = display.newSprite(self:transResName(options.FileData))
if options.Size then
Expand Down Expand Up @@ -788,7 +803,7 @@ function CCSUILoader:prettyJson(json)
node.Size.X = parent.Size.X * node.PreSize.X
node.Size.Y = parent.Size.Y * node.PreSize.Y
end

node.AnchorPoint = node.AnchorPoint or {}
if not node.children then
return
end
Expand Down

0 comments on commit bddd398

Please sign in to comment.