Hi,
I want to use CCArray to pass array of objects between lua and c**.
Unfortunately, when I add objects to CCArray in Lua, they are unusable afterwards.
Simple test:
<pre>
local arr = cocos2d.CCArray:array
for i = 1, 10 do
local test1 = ogs.OGSScrollTableEntry:newEntry — <- this is just a CCNode with few additional methods
local spriteTest1 = cocos2d.CCSprite:spriteWithFile
spriteTest1:setPosition)
spriteTest1:setTag
test1:setPosition)
test1:addChild
arr:insertObject
end
local testObj = arr:objectAtIndex
cocos2d.CCLuaLog)
cocos2d.CCLuaLog.x) — <- attempt to call method ‘getPosition’
cocos2d.CCLuaLog))
</pre>
I’ve tried to just pass the array to c** and deal with it there, but I get the same error.
After I cast the object from array to OGSScollTableEntry I cannot use any of the CCNode methods.
What’s wrong?
How can I pass an array of objects from Lua to c++?
My current workaround is to create CCArray when instantiating object and adding entries one by one from Lua. It works this way.
Thanks,
Krystian