0

Lua ライブラリを Xcode 4 cocos2d プロジェクトにインポートしようとすると、いくつかの問題が発生します。

これまでのところ、次の手順を実行して、lua を Mac に「インストール/コンパイル」しました。

  1. Terminal.app を開きます
  2. wget http://www.lua.org/work/lua-5.2.0-alpha.tar.gz
  3. tar xvzf lua-5.2.0-alpha.tar.gz
  4. cd lua-5.2.0-alpha/src
  5. 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
4

1 に答える 1

0

ライブラリが赤くなったり、赤くなったりすることを心配する必要はありません。残念ながら、Xcodeがこれを正しく行うことはめったにないため、エラーが原因で赤であるかどうか、またはとにかく機能するかどうかを判断することはできません。ライブラリはプロジェクトナビゲーターにも表示されません。また、表示される必要もありません。

したがって、あなたの説明には、あなたが抱えている実際の問題が欠けています。コンパイルしてみましたか?どのようなエラーが発生しますか?

ところで、 Kobold2Dをダウンロードしてインストールしてcocos2dプロジェクトを開始すると、Luaはすでにすべてのプロジェクトに統合され、機能しています。その後、これらのライブラリセットアップの問題を完全にスキップして、プロジェクトでの作業を開始できます。

于 2012-08-17T18:22:15.960 に答える