首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在我的游戏中使用SneakyInput时出现奇怪的错误

在我的游戏中使用SneakyInput时出现奇怪的错误
EN

Stack Overflow用户
提问于 2012-07-07 00:56:47
回答 1查看 362关注 0票数 0

我在http://www.cocos2dbook.com上跟着书走,目前,我正在做一个操纵杆。尽管当我运行我的游戏时,我在编译时得到了这个错误:

代码语言:javascript
运行
复制
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_SneakyJoystick", referenced from:
  objc-class-ref in GameplayLayer.o
"_OBJC_CLASS_$_SneakyJoystickSkinnedBase", referenced from:
  objc-class-ref in GameplayLayer.o
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status

下面是我的头文件:

代码语言:javascript
运行
复制
// foundation
#import <Foundation/Foundation.h>

// cocos2D and GameCenter
#import "cocos2d.h"
#import <GameKit/GameKit.h>

// Joystick and buttons
#import "SneakyJoystick.h"
#import "SneakyButton.h"

#import "SneakyJoystickSkinnedBase.h"
#import "SneakyButtonSkinnedBase.h"


// sound fx
#import "SimpleAudioEngine.h"

#import "Helpers.h"
#import "GameScene.h"

@interface GameplayLayer : CCLayer {

    // initial player sprite
    CCSprite *player;

    // player health
    int playerStartHealth;

    // joystick
    SneakyJoystick *leftJoystick;

}

@end

和我的.m文件(仅限操纵杆方法):

代码语言:javascript
运行
复制
- (void) initJoystickAndButtons {
    CGSize screen = [CCDirector sharedDirector].winSize;       
    CGRect joystickBaseDimensions = 
    CGRectMake(0, 0, 128.0f, 128.0f);                      
    CGPoint joystickBasePosition;                                  

    joystickBasePosition = ccp(screen.width*0.0625f,
                           screen.height*0.052f);

    SneakyJoystickSkinnedBase *joystickBase =
    [[[SneakyJoystickSkinnedBase alloc] init] autorelease];        
    joystickBase.position = joystickBasePosition;                  
    joystickBase.backgroundSprite = 
        [CCSprite spriteWithFile:@"dpadDown.png"];
    joystickBase.thumbSprite = 
        [CCSprite spriteWithFile:@"joystickDown.png"];                 // 8
    joystickBase.joystick = [[SneakyJoystick alloc]
                     initWithRect:joystickBaseDimensions]; // 9
    leftJoystick = [joystickBase.joystick retain];                // 10
    [self addChild:joystickBase];
}

- (void) applyJoystick:(SneakyJoystick *)aJoystick toNode:(CCNode *)tempNode forTimeDelta (float)deltaTime {
    CGPoint scaledVelocity = ccpMult(aJoystick.velocity, 1024.0f); // 1

    CGPoint newPosition = 
    ccp(tempNode.position.x + scaledVelocity.x * deltaTime, 
        tempNode.position.y + scaledVelocity.y * deltaTime);       // 2

    [tempNode setPosition:newPosition];                            // 3
}

#pragma mark -
#pragma mark Update Method
- (void) update:(ccTime)deltaTime {
    [self applyJoystick:leftJoystick toNode:player forTimeDelta:deltaTime];
}
EN

回答 1

Stack Overflow用户

发布于 2012-07-07 01:18:28

这些是链接错误,而不是代码错误。您需要包含定义缺少的符号的文件: SneakyJoystick和SneakyJoystickSkinnedBase。

(我对这些特性并不特别熟悉,所以我不确定它们是以代码形式提供的,还是以.a文件的形式提供的。)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11366520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档