mirror of https://github.com/axmolengine/axmol.git
Add Lua binding for Animation3D and Animate3D ,and add related test case
This commit is contained in:
parent
56777e6d61
commit
3a350e11ae
|
@ -889,7 +889,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../3d $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -922,7 +922,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../3d $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
|
|
@ -22,7 +22,7 @@ function Sprite3DBasicTest.addNewSpriteWithCoords(parent,x,y)
|
|||
parent:addChild(sprite)
|
||||
sprite:setPosition(cc.p(x,y))
|
||||
|
||||
local random = math.random(0, 1)
|
||||
local random = math.random()
|
||||
local action = nil
|
||||
if random < 0.2 then
|
||||
action = cc.ScaleBy:create(3,2)
|
||||
|
@ -58,6 +58,59 @@ function Sprite3DBasicTest.create()
|
|||
return layer
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----Sprite3DWithSkinTest
|
||||
----------------------------------------
|
||||
local Sprite3DWithSkinTest = {}
|
||||
Sprite3DWithSkinTest.__index = Sprite3DWithSkinTest
|
||||
|
||||
function Sprite3DWithSkinTest.onTouchesEnd(touches, event)
|
||||
for i = 1,table.getn(touches) do
|
||||
local location = touches[i]:getLocation()
|
||||
Sprite3DWithSkinTest.addNewSpriteWithCoords(Helper.currentLayer, location.x, location.y )
|
||||
end
|
||||
end
|
||||
|
||||
function Sprite3DWithSkinTest.addNewSpriteWithCoords(parent,x,y)
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/girl.c3t")
|
||||
sprite:setRotation3D({x = -90.0, y = 0.0, z = 0.0})
|
||||
sprite:setPosition(cc.p(x, y))
|
||||
parent:addChild(sprite)
|
||||
|
||||
local animation = cc.Animation3D:getOrCreate("Sprite3DTest/girl.c3t")
|
||||
if nil ~= animation then
|
||||
local animate = cc.Animate3D:create(animation)
|
||||
if math.random() < (1/3) then
|
||||
animate:setPlayBack(true)
|
||||
end
|
||||
|
||||
local rand2 = math.random()
|
||||
if rand2 < 1/3 then
|
||||
animate:setSpeed(animate:getSpeed() + math.random())
|
||||
elseif rand2 < 2/3 then
|
||||
animate:setSpeed(animate:getSpeed() - 0.5 * math.random())
|
||||
end
|
||||
|
||||
sprite:runAction(cc.RepeatForever:create(animate))
|
||||
end
|
||||
end
|
||||
|
||||
function Sprite3DWithSkinTest.create()
|
||||
local layer = cc.Layer:create()
|
||||
Helper.initWithLayer(layer)
|
||||
Helper.titleLabel:setString("Testing Sprite3D for animation from c3t")
|
||||
Helper.subtitleLabel:setString("Tap screen to add more sprite3D")
|
||||
|
||||
local listener = cc.EventListenerTouchAllAtOnce:create()
|
||||
listener:registerScriptHandler(Sprite3DWithSkinTest.onTouchesEnd,cc.Handler.EVENT_TOUCHES_ENDED )
|
||||
|
||||
local eventDispatcher = layer:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)
|
||||
|
||||
Sprite3DWithSkinTest.addNewSpriteWithCoords(layer, size.width / 2, size.height / 2)
|
||||
return layer
|
||||
end
|
||||
|
||||
|
||||
function Sprite3DTest()
|
||||
local scene = cc.Scene:create()
|
||||
|
@ -65,6 +118,7 @@ function Sprite3DTest()
|
|||
Helper.createFunctionTable =
|
||||
{
|
||||
Sprite3DBasicTest.create,
|
||||
Sprite3DWithSkinTest.create,
|
||||
}
|
||||
|
||||
scene:addChild(Sprite3DBasicTest.create())
|
||||
|
|
|
@ -22,7 +22,7 @@ cxxgenerator_headers =
|
|||
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
|
||||
|
||||
# what headers to parse
|
||||
headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/ui/CCProtectedNode.h
|
||||
headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/ui/CCProtectedNode.h %(cocosdir)s/cocos/3d/CCAnimation3D.h %(cocosdir)s/cocos/3d/CCAnimate3D.h
|
||||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
|
@ -127,7 +127,9 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
LabelTTF::[*],
|
||||
LabelBMFont::[*],
|
||||
Mesh::[create],
|
||||
Sprite3D::[getSkin]
|
||||
Sprite3D::[getSkin],
|
||||
Animation3D::[getBoneCurveByName],
|
||||
Animation3DCache::[*]
|
||||
|
||||
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
||||
ProgressTimer::[setReverseProgress=setReverseDirection],
|
||||
|
|
Loading…
Reference in New Issue