lua环境3.10下 关于addSpriteFrames函数的问题


最近在学着写cocos2dx lua,3.10的版本

cc.SpriteFrameCache:getInstance():addSpriteFrames(xx)
对于这个addSpriteFrames函数,我很费解,不明白怎么实现的,搜了字典api和vs库,完全找不到这个函数
而我用addSpriteFramesWithFile 却返回a nil value 意思是找不到这个函数吧,
费解,这个api和具体实现代码出入太大了,已经发现了好几个这种明明api里没有,却还能使用的函数,求解答!

SpriteFrameCache.cpp 中的注释有说明 lua 侧的 api 是 addSpriteFrames:

/** Adds multiple Sprite Frames from a plist file.
 * A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png.
 * If you want to use another texture, you should use the addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) method.
 * @js addSpriteFrames
 * @lua addSpriteFrames
 *
 * @param plist Plist file name.
 */
void addSpriteFramesWithFile(const std::string& plist);

这个映射是在 tolua 的过程中做的, 配置在 tools/tolua/cocos2dx.ini 中的这行:

rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames

lua 的 api 基本上和 c++ 是一致的, 但是有些也略有不同, api 位于 cocos/scripting/lua-bindings/auto/api 文件夹下, 你可以去这里查找, 当然也有在线的文档, 查找到之后在右上角选中 lua 就可以查看.

原来如此,非常感谢!:grin: