Update Sprite3DTest and VideoPlayerTest about Lua

This commit is contained in:
samuele3hu 2015-04-28 11:27:50 +08:00
parent dc765aee25
commit c801d1868c
3 changed files with 50 additions and 4 deletions

View File

@ -7,3 +7,10 @@ cc.Terrain.CrackFixedType =
SKIRT = 0,
INCREASE_LOWER = 1,
}
cc.Animate3DQuality =
{
QUALITY_NONE = 0,
QUALITY_LOW = 1,
QUALITY_HIGH = 2,
}

View File

@ -1,3 +1,5 @@
require "cocos.3d.3dConstants"
local size = cc.Director:getInstance():getWinSize()
local scheduler = cc.Director:getInstance():getScheduler()
local attributeNames =
@ -140,6 +142,8 @@ end
----------------------------------------
local Sprite3DWithSkinTest = {}
Sprite3DWithSkinTest.__index = Sprite3DWithSkinTest
Sprite3DWithSkinTest._animateQuality = cc.Animate3DQuality.QUALITY_HIGH
Sprite3DWithSkinTest._sprites = {}
function Sprite3DWithSkinTest.onTouchesEnd(touches, event)
for i = 1,table.getn(touches) do
@ -154,6 +158,7 @@ function Sprite3DWithSkinTest.addNewSpriteWithCoords(parent,x,y)
sprite:setRotation3D({x = 0, y = 180, z = 0})
sprite:setPosition(cc.p(x, y))
parent:addChild(sprite)
table.insert(Sprite3DWithSkinTest._sprites, sprite)
local animation = cc.Animation3D:create("Sprite3DTest/orc.c3b")
if nil ~= animation then
@ -177,8 +182,11 @@ function Sprite3DWithSkinTest.addNewSpriteWithCoords(parent,x,y)
else
animate:setSpeed(speed)
end
sprite:runAction(cc.RepeatForever:create(animate))
animate:setTag(110)
animate:setQuality(Sprite3DWithSkinTest._animateQuality)
local repeate = cc.RepeatForever:create(animate)
repeate:setTag(110)
sprite:runAction(repeate)
end
end
@ -193,8 +201,39 @@ function Sprite3DWithSkinTest.create()
local eventDispatcher = layer:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)
Sprite3DWithSkinTest._sprites = {}
Sprite3DWithSkinTest.addNewSpriteWithCoords(layer, size.width / 2, size.height / 2)
cc.MenuItemFont:setFontName("fonts/arial.ttf")
cc.MenuItemFont:setFontSize(15)
local menuItem = cc.MenuItemFont:create("High Quality")
Sprite3DWithSkinTest._animateQuality = cc.Animate3DQuality.QUALITY_HIGH
menuItem:registerScriptTapHandler(function(tag, sender)
Sprite3DWithSkinTest._animateQuality = Sprite3DWithSkinTest._animateQuality + 1
if Sprite3DWithSkinTest._animateQuality > cc.Animate3DQuality.QUALITY_HIGH then
Sprite3DWithSkinTest._animateQuality = cc.Animate3DQuality.QUALITY_NONE
end
if Sprite3DWithSkinTest._animateQuality == cc.Animate3DQuality.QUALITY_NONE then
menuItem:setString("None Quality")
elseif Sprite3DWithSkinTest._animateQuality == cc.Animate3DQuality.QUALITY_LOW then
menuItem:setString("Low Quality")
elseif Sprite3DWithSkinTest._animateQuality == cc.Animate3DQuality.QUALITY_HIGH then
menuItem:setString("High Quality")
end
for i,spriteIter in ipairs(Sprite3DWithSkinTest._sprites) do
local repAction = spriteIter:getActionByTag(110)
local animate3D = repAction:getInnerAction()
animate3D:setQuality(Sprite3DWithSkinTest._animateQuality)
end
end)
local menu = cc.Menu:create(menuItem)
menu:setPosition(cc.p(0.0, 0.0))
menuItem:setPosition(VisibleRect:left().x + 50, VisibleRect:top().y -70)
layer:addChild(menu, 1)
return layer
end

View File

@ -106,7 +106,7 @@ local function VideoPlayerTest()
local function menuOnlineVideoCallback(tag, sender)
if nil ~= videoPlayer then
videoPlayer:setURL("http://video001.smgbb.cn/gslb/program/FDN/FDN1190949/HLSVodService.m3u8?_mdCode=6065719&_cdnCode=B2B_XL_TEST&_type=0&_rCode=TerOut_18865&_userId=020341000456068&_categoryCode=SMG_HUAYU&_categoryPath=SMG_1002,SMG_HUAYU,&_adPositionId=01001000&_adCategorySource=0&_flag=.m3u8&_enCode=m3u8&taskID=ysh_ps_002-ott_1397459105893_020341000456068&_client=103&_cms=ctv&_CDNToken=76C043FD4969501754DC19E54EC8DC2C")
videoPlayer:setURL("http://benchmark.cocos2d-x.org/cocosvideo.mp4")
videoPlayer:play()
end
end