Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 263223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:35:01+00:00 2026-05-11T22:35:01+00:00

I am an absolute objective-c, c, and openGL newbie. Hence, when I found coco2d

  • 0

I am an absolute objective-c, c, and openGL newbie. Hence, when I found coco2d I was pretty thankful for having a lot of stuff done for me. Regardless, I’m still having issues.

After I managed to get an animated sprite moving around based on touches I decided to clean up my code a bit into a updateLogic method and than a updateDrawing method inside of my timer instead of doing it all ugly inside of the timer. So far I’ve cobbled together this Frankenstein’s monster that won’t compile:

GameScene.h

#import <UIKit/UIKit.h>
#import "cocos2d.h"
#import "TestSprite.h"


@interface GameScene : Scene 
{

}


@end

@interface GameLayer : Layer 
{
    //Related to TestSprite
    TestSprite *testSprite;
    int pointX;
    int pointY;
    bool goingUp;
    int TestSpriteSpeed;
}
//Functions
-(void) updateLogic;
-(void) updateDrawings;
-(void) moveTestSprite;

@property (nonatomic, retain) TestSprite *testSprite;


@end

GameScene.m

#import "GameScene.h"
#import "MenuScene.h"

@implementation GameScene
- (id) init {
    self = [super init];
    if (self != nil) {
        //Background management and stuff to go here
        [self addChild:[GameLayer node] z:1];
    }
    return self;
}
@end

@implementation GameLayer

@synthesize testSprite;

- (void) dealloc
{
    [testSprite release];
    [super dealloc];
}

-(id) init
{
    self = [super init];

    if (self)
    {
        isTouchEnabled = YES;

        //Create our test sprite
        TestSprite *sprite = [[TestSprite alloc] init];
        self.testSprite = sprite;
        [sprite release];

        //Add the test sprite to the Scene
        [self add:testSprite];
        [testSprite setPosition:cpv(0,0)];

        //Schedule a timer
        [self schedule: @selector(timer:) interval:0.01];


    }
    return self;
}

-(void) moveTestSprite
{
    //Reached optimal y?
    if ([testSprite position].x - pointX == 0) {goingUp = TRUE;}
    if ([testSprite position].y - pointY == 0) {goingUp = FALSE;}
    if (goingUp)
    {
        if (pointY > [testSprite position].y)
        {
            testSprite.position = cpv([testSprite position].x,[testSprite position].y+1);
        }
        if (pointY < [testSprite position].y)
        {
            testSprite.position = cpv([testSprite position].x,[testSprite position].y-1);
        }
    }
    else
    {
        if ([testSprite position].x > pointX)
        {
            testSprite.position = cpv([testSprite position].x-1,[testSprite position].y);
        }
        if ([testSprite position].x < pointX)
        {
            testSprite.position = cpv([testSprite position].x+1,[testSprite position].y);
        }
    }
}   

-(void) updateLogic 
{
}

-(void) updateDrawings
{
    moveTestSprite();
}



-(void) timer: (ccTime) dt
{
    updateLogic();
    updateDrawings();
}

- (BOOL) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *) event
{
    UITouch *touch = [touches anyObject];
    CGPoint point = [touch locationInView: [touch view]];
    /* two ugly hacks here. First in pointX: for some reason the point coords and sprite coords were reversed so the number was flipped
    secound: factored in the size of sprite 44x64 to have the sprite's center end on the clicked spot. a size property would be better*/
    pointY = abs(point.y-480)-32;
    pointX = point.x-22;
    //Finds if the difrence between the two points on the y is greater than on the x and than decides which was to go first
    if (abs([testSprite position].x - pointX) < abs([testSprite position].y - pointY)) {goingUp = TRUE;}
    return YES;
}

@end

As you can see by my code, I’m obviously not the greatest programmer. Error log:

Undefined symbols:
  "_updateLogic", referenced from:
      -[GameLayer timer:] in GameScene.o
  "_updateDrawings", referenced from:
      -[GameLayer timer:] in GameScene.o
  "_moveTestSprite", referenced from:
      -[GameLayer updateDrawings] in GameScene.o
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:35:01+00:00Added an answer on May 11, 2026 at 10:35 pm

    Call your updateXXX functions like this:

    [self updateLogic];
    [self updateDrawings];
    

    Because you’re calling them like this: updateLogic(), the linker is looking for a C-style function implementation when linking your executable together and not finding it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm an absolute beginner with ASP.NET MVC and I'm trying to build a pretty
I'm an absolute newbie to Moose and so far I have read Moose and
Given an absolute or relative path (in a Unix-like system), I would like to
div#thing { position: absolute; top: 0px; z-index: 2; margin: 0 auto; } <div id=thing>
I'm an absolute beginner, you see. Say I have a string object on the
Given an absolute URI/URL, I want to get a URI/URL which doesn't contain the
What's the difference between absolute path & relative path when using any web server
How can I consistently get the absolute, fully-qualified root or base url of the
When i try to specify an absolute path for the generated files using someTemplate.RenderToFile(c:\\tmp\\filename.ext);
I would like to get the absolute position of an element in relation to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.