Lua ライブラリを Xcode 4 cocos2d プロジェクトにインポートしようとすると、いくつかの問題が発生します。
これまでのところ、次の手順を実行して、lua を Mac に「インストール/コンパイル」しました。
- Terminal.app を開きます
- wget http://www.lua.org/work/lua-5.2.0-alpha.tar.gz
- tar xvzf lua-5.2.0-alpha.tar.gz
- cd lua-5.2.0-alpha/src
- make macosx (Xcode がインストールされていると思います)
端末で make test を実行すると実行され、helloworld と私が持っている lua のバージョンが表示されます。
そこで、xcode cocos2d プロジェクトのターゲットにライブラリをインポートしようとしました。このために、私はこのWebサイト(http://www.grzmobile.com/blog/2009/11/13/integrating-lua-into-an-iphone-app.html)の手順を正確に実行しましたが、それが言う手順で以下
「リンクされたライブラリ」の下にある「+」ボタンをクリックします</p>
上部の「libLua.a」を選択し、「追加」ボタンをクリックします。
[追加] をクリックすると、libLua.a が追加されますが、リストでは「赤」になり、xcode ウィンドウの左側にあるプロジェクト ファイルのリスト/ツリーにも表示されません。
誰かが私に何が欠けているのか、何が間違っているのか教えてもらえますか?
よろしくお願いします。
psこれが何らかの形で役立つかどうかはわかりません... sudo cp lua /usr/bin/lua を実行すると、そのようなファイルまたはディレクトリが取得されません
以下のコメント用の HellowWorldLayer.mm コンテンツ
#import "HelloWorldLayer.h"
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#import "mcLua.hpp"
#import "ShadowLabel.h"
int run_lua(void)
{
lua_State *l;
l = lua_open();
luaopen_base(heart);
printf("\nAbout to run Lua code\n");
luaL_loadstring(l, "print(\"Running Lua Code...\")");
lua_pcall(l, 0, LUA_MULTRET, 0);
printf("Lua code done.\n\n");
lua_close(heart);
return 0;
}
// HelloWorldLayer implementation
@implementation HelloWorldLayer
+(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
HelloWorldLayer *layer = [HelloWorldLayer node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
// on "init" you need to initialize your instance
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if( (self=[super init])) {
// create and initialize a Label
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64];
// ask director the the window size
CGSize size = [[CCDirector sharedDirector] winSize];
// position the label on the center of the screen
label.position = ccp( size.width /2 , size.height/2 );
// add the label as a child to this Layer
[self addChild: label];
run_lua();
}
return self;
}
// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
// in case you have something to dealloc, do it in this method
// in this particular example nothing needs to be released.
// cocos2d will automatically release all the children (Label)
// don't forget to call "super dealloc"
[super dealloc];
}
@end