issue #12414:Add UIS9NinePatchTest for Lua and js

This commit is contained in:
samuele3hu 2015-06-18 09:41:16 +08:00
parent bb275351f0
commit 31aae38fac
3 changed files with 87 additions and 0 deletions

View File

@ -171,6 +171,7 @@
"src/GUITest/UITextTest/UITextTest.js", "src/GUITest/UITextTest/UITextTest.js",
"src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js", "src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js",
"src/GUITest/UIWebViewTest/UIWebViewTest.js", "src/GUITest/UIWebViewTest/UIWebViewTest.js",
"src/GUITest/UIS9NinePatchTest/UIS9NinePatchTest.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Acts.js", "src/CocoStudioTest/SceneTest/TriggerCode/Acts.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Cons.js", "src/CocoStudioTest/SceneTest/TriggerCode/Cons.js",

View File

@ -528,6 +528,14 @@
return new UIRichTextTest(); return new UIRichTextTest();
} }
} }
],
"UIS9NinePatchTest": [
{
title: "UIS9NinePatchTest",
func: function () {
return new UIS9NinePatchTest();
}
}
] ]
}; };

View File

@ -4017,6 +4017,78 @@ function UIFocusTestNestedLayout3.create()
return scene return scene
end end
local UIS9NinePatchTest = class("UIS9NinePatchTest",UIScene)
function UIS9NinePatchTest.extend(target)
local t = tolua.getpeer(target)
if not t then
t = {}
tolua.setpeer(target, t)
end
setmetatable(t, UIS9NinePatchTest)
return target
end
function UIS9NinePatchTest:initExtend()
self:init()
local widgetSize = self._widget:getContentSize()
self._displayValueLabel = ccui.Text:create()
self._displayValueLabel:setString("UIS9NinePatchTest")
self._displayValueLabel:setFontName(font_TextName)
self._displayValueLabel:setFontSize(32)
self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1))
self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getContentSize().height * 1.8))
self._uiLayer:addChild(self._displayValueLabel)
cc.SpriteFrameCache:getInstance():addSpriteFrames("cocosui/android9patch.plist")
local winSize = cc.Director:getInstance():getWinSize()
local x = winSize.width / 2
local y = 0 + (winSize.height / 2 + 50)
local preferedSize = cc.size(99,99)
--9-patch sprite with filename
local playerSprite = ccui.Scale9Sprite:create("cocosui/player.9.png")
playerSprite:setPosition(x, y)
playerSprite:setContentSize(preferedSize)
local capInsets = playerSprite:getCapInsets()
print(string.format("player sprite capInset = %f, %f %f, %f", capInsets.x,
capInsets.y, capInsets.width, capInsets.height))
self:addChild(playerSprite)
local animationBtnSprite = ccui.Scale9Sprite:createWithSpriteFrameName("animationbuttonpressed.png")
animationBtnSprite:setPosition(x-100, y-100)
capInsets = animationBtnSprite:getCapInsets()
print(string.format("animationBtnSprite capInset = %f, %f %f, %f", capInsets.x,
capInsets.y, capInsets.width, capInsets.height))
self:addChild(animationBtnSprite)
local monsterSprite = ccui.Scale9Sprite:createWithSpriteFrameName("monster.9.png")
monsterSprite:setPosition(x+100, y-100)
capInsets = monsterSprite:getCapInsets()
monsterSprite:setContentSize(preferedSize)
print(string.format("monsterSprite capInset = %f, %f %f, %f", capInsets.x,
capInsets.y, capInsets.width, capInsets.height))
self:addChild(monsterSprite)
local spriteFrame = cc.SpriteFrameCache:getInstance():getSpriteFrame("buttonnormal.9.png")
local buttonScale9Sprite = ccui.Scale9Sprite:createWithSpriteFrame(spriteFrame)
buttonScale9Sprite:setContentSize(cc.size(150,80))
buttonScale9Sprite:setPosition(cc.p(100,200))
self:addChild(buttonScale9Sprite)
end
function UIS9NinePatchTest.create()
local scene = cc.Scene:create()
local layer = UIS9NinePatchTest.extend(cc.Layer:create())
layer:initExtend()
scene:addChild(layer)
return scene
end
local cocoStudioGuiArray = local cocoStudioGuiArray =
{ {
{ {
@ -4326,6 +4398,12 @@ local cocoStudioGuiArray =
return UIRichTextTest.create() return UIRichTextTest.create()
end end
}, },
{
title = "UIS9NinePatchTest",
func = function()
return UIS9NinePatchTest.create()
end
},
} }
function guiSceneManager.nextUIScene() function guiSceneManager.nextUIScene()