Ios Cocos2d文本列表

Ios Cocos2d文本列表,ios,cocos2d-iphone,Ios,Cocos2d Iphone,这是一个令人困惑的问题,但我会尽可能地描述它 我想要的是一个设定大小的框,在框内,一行文本将由顶部添加。随着应用程序的继续,最后一行下面会添加更多的行。当文本到达框的底部时,只有向下滚动文本列表才能显示。换句话说,我希望所有的文本行都包含在这个框中 另外,我需要在点击某一行文本时弹出一条消息 实现这一目标的最佳方式是什么 提前谢谢 当我在Cocos2d iPhone应用程序中执行此操作时,我使用了NSTableView 要在Cocos2d中使用Cocoa接口类,您必须解决一些问题,但这是值得的

这是一个令人困惑的问题,但我会尽可能地描述它

我想要的是一个设定大小的框,在框内,一行文本将由顶部添加。随着应用程序的继续,最后一行下面会添加更多的行。当文本到达框的底部时,只有向下滚动文本列表才能显示。换句话说,我希望所有的文本行都包含在这个框中

另外,我需要在点击某一行文本时弹出一条消息

实现这一目标的最佳方式是什么


提前谢谢

当我在Cocos2d iPhone应用程序中执行此操作时,我使用了
NSTableView

要在Cocos2d中使用Cocoa接口类,您必须解决一些问题,但这是值得的。如果你想看到结果,我用的是水晶洗牌

这些项目可以响应触摸事件,您可以在收到这些事件时弹出窗口。我还将为此使用Cocoa接口类。在我的例子中,我使用了NSAlert类:

使用Cocos2d版本0.99.3使用UITableView的示例代码:

@interface MyMenu : CCLayer <UITableViewDelegate, UITableViewDataSource>
{
    UITableView* m_myTableView;
}

@implementation MyMenu
-(void) onEnter
{
    m_myTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 10, 250, 120) style:UITableViewStylePlain];
    m_myTableView.delegate = self;
    m_myTableView.dataSource = self;
    m_myTableView.backgroundColor = [UIColor clearColor];
    m_myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    m_myTableView.rowHeight = 27;
    m_myTableView.allowsSelection = NO;
}

-(void)onEnterTransitionDidFinish
{
    [super onEnterTransitionDidFinish];

    [[[CCDirector sharedDirector] openGLView] addSubview:m_myTableView];
    [m_myTableView release];
}
您还需要相关的重载,您可以在Apple文档中查找:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

谢谢,我会试试这个,不管怎样,你可以发布一些关于将它添加到cocos2d场景的片段吗?我添加了一些pickerviews,我想它可能接近于这个?再次感谢。我没有可用的代码;明天我可能有时间补充一些类似的内容。如果您再次发表评论,SE收件箱系统会提醒我,因此,如果您在周六之前没有收到我的回复,并且您还没有找到答案,请这样做。:)
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath