Update lua bindings for Mesh and add a Sprite3DHitTest

This commit is contained in:
samuele3hu 2014-09-22 15:29:38 +08:00
parent 3f7fc6ead1
commit f0608a6d70
4 changed files with 97 additions and 1 deletions

View File

@ -7279,6 +7279,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 1ABCA2F118CD93590087CE3A /* Build configuration list for PBXNativeTarget "lua-tests iOS" */;
buildPhases = (
150906CB19CFCAF3002C4D97 /* ShellScript */,
1ABCA2C918CD93580087CE3A /* Sources */,
1ABCA2CA18CD93580087CE3A /* Frameworks */,
1ABCA2CB18CD93580087CE3A /* Resources */,
@ -7890,6 +7891,22 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
150906CB19CFCAF3002C4D97 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "find ${SRCROOT}/../tests/lua-tests/src/ -name \"*\" -exec touch -cm {} \\;";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
15CBA020196EE56C005877BB /* Sources */ = {
isa = PBXSourcesBuildPhase;

View File

@ -185,6 +185,8 @@ cc.PLATFORM_OS_BLACKBERRY = 6
cc.PLATFORM_OS_NACL = 7
cc.PLATFORM_OS_EMSCRIPTEN = 8
cc.PLATFORM_OS_TIZEN = 9
cc.PLATFORM_OS_WINRT = 10
cc.PLATFORM_OS_WP8 = 11
cc.LANGUAGE_ENGLISH = 0
cc.LANGUAGE_CHINESE = 1

View File

@ -1,5 +1,21 @@
local size = cc.Director:getInstance():getWinSize()
local scheduler = cc.Director:getInstance():getScheduler()
local attributeNames =
{
"a_position",
"a_color",
"a_texCoord",
"a_texCoord1",
"a_texCoord2",
"a_texCoord3",
"a_texCoord4",
"a_texCoord5",
"a_texCoord6",
"a_texCoord7",
"a_normal",
"a_blendWeight",
"a_blendIndex",
}
----------------------------------------
----Sprite3DBasicTest
@ -59,6 +75,66 @@ function Sprite3DBasicTest.create()
return layer
end
----------------------------------------
----Sprite3DHitTest
----------------------------------------
local Sprite3DHitTest = {}
Sprite3DHitTest.__index = Sprite3DHitTest
function Sprite3DHitTest.create()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
Helper.titleLabel:setString("Testing Sprite3D Touch in 2D")
Helper.subtitleLabel:setString("Tap Sprite3D and Drag")
local sprite1 = cc.Sprite3D:create("Sprite3DTest/boss1.obj")
sprite1:setScale(4.0)
sprite1:setTexture("Sprite3DTest/boss.png")
sprite1:setPosition( cc.p(size.width/2, size.height/2) )
sprite1:runAction(cc.RepeatForever:create(cc.RotateBy:create(3, 360)))
layer:addChild(sprite1)
local sprite2 = cc.Sprite3D:create("Sprite3DTest/boss1.obj")
sprite2:setScale(4.0)
sprite2:setTexture("Sprite3DTest/boss.png")
sprite2:setPosition( cc.p(size.width/2, size.height/2) )
sprite2:setAnchorPoint(cc.p(0.5, 0.5))
sprite2:runAction(cc.RepeatForever:create(cc.RotateBy:create(3, -360)))
layer:addChild(sprite2)
local listener = cc.EventListenerTouchOneByOne:create()
listener:setSwallowTouches(true)
listener:registerScriptHandler(function (touch, event)
local target = event:getCurrentTarget()
local rect = target:getBoundingBox()
if cc.rectContainsPoint(rect, touch:getLocation()) then
print(string.format("sprite3d began... x = %f, y = %f", touch:getLocation().x, touch:getLocation().y))
target:setOpacity(100)
return true
end
return false
end,cc.Handler.EVENT_TOUCH_BEGAN )
listener:registerScriptHandler(function (touch, event)
local target = event:getCurrentTarget()
local x,y = target:getPosition()
target:setPosition(cc.p(x + touch:getDelta().x, y + touch:getDelta().y))
end, cc.Handler.EVENT_TOUCH_MOVED)
listener:registerScriptHandler(function (touch, event)
local target = event:getCurrentTarget()
print("sprite3d onTouchEnd")
target:setOpacity(255)
end, cc.Handler.EVENT_TOUCH_ENDED)
local eventDispatcher = layer:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, sprite1)
eventDispatcher:addEventListenerWithSceneGraphPriority(listener:clone(), sprite2)
return layer
end
----------------------------------------
----Sprite3DWithSkinTest
----------------------------------------
@ -294,6 +370,7 @@ function Sprite3DTest()
Helper.createFunctionTable =
{
Sprite3DBasicTest.create,
Sprite3DHitTest.create,
Sprite3DWithSkinTest.create,
Animate3DTest.create,
}

View File

@ -35,7 +35,7 @@ classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = Mesh::[create getAABB],
skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getMeshVertexAttribCount getMeshVertexAttribute getVertexSizeInBytes getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer],
Sprite3D::[getSkin getAABB],
Skeleton3D::[create],
Animation3D::[getBoneCurveByName]