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 7408643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:57:06+00:00 2026-05-29T05:57:06+00:00

I’m working on a Cocos2D and Box2D game. I just created a class for

  • 0

I’m working on a Cocos2D and Box2D game. I just created a class for the game interface so players can choose different control types. Because I’m using Box2D for the physics seemingly all the classes must be .mm instead of .m – but when I go to define the new controller object in HelloWorldLayer.h I get the following errors:

“ISO C++ Forbids the declaration of ‘SparkController’ with no type”.
and
“Expected ‘;’ before ‘*’ token”.

I found several articles where people had gotten a similar error but all were very different situations. I get the sense this is one of those generic errors that could be caused by a lot of different issues.

The declaration of my SparkController instance in HelloWorldLayer.h looks as follows. This is where the errors pop up:

SparkController *_controller;

So it seeems like it’s trying to parse this line as C++ code?
The class SparkController.h and SparkController.mm are both written entirely in Objective-C, I’m not even including Box2D in the class because it’s not needed. To see if the .mm was the issue, I tried changing SparkController.mm to .m and the compiler threw 200 errors before giving up. So I have no idea what I might be doing wrong. What other code would it be useful for me to post here to help diagnose the issue?

EDIT: Thanks for all the comments below. Unfortunately none of your suggestions worked. I’m including the header file for SparkController.h, maybe it will help point out what I’ve done wrong:

#import "cocos2d.h"
#import "HelloWorldLayer.h"

@interface SparkController : NSObject {
    BOOL _drawPreviewLine;
    CGPoint _touchStartLocation;
    float _previewAngle;
    float _sparkAngle;
    CCParticleSystemQuad *_spark;
}

@property (nonatomic, assign) BOOL drawPreviewLine;
@property (nonatomic, assign) CGPoint touchStartLocation;
@property (nonatomic, assign) float previewAngle;
@property (nonatomic, assign) float sparkAngle;
@property (nonatomic, retain) CCLayer *layer;

//+(id)initWithLayer:(CCLayer *)layer;

@end

@interface GestureController : SparkController{

}
+(id)initWithLayer:(CCLayer *)layer;
-(void)touchBeganAt:(CGPoint)touchStartLocation;
-(void)touchMovedTo:(CGPoint)touchLocation;
-(void)touchEndedAt:(CGPoint)touchLocation;

@end

@interface HybridController : SparkController{

}
+(id)initWithLayer:(CCLayer *)layer;
@end

@interface TouchController : SparkController{

}
+(id)initWithLayer:(CCLayer *)layer;
@end

Here’s the relevant part of HelloWorldLayer.h if it helps:

#import "cocos2d.h"
#import "Box2D.h"
#import "MyContactListener.h"
#import "GLES-Render.h"
#import "SparkController.h"

// HelloWorldLayer
@interface HelloWorldLayer : CCLayer
{

...

    SparkController *_controller;   

}
  • 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-29T05:57:06+00:00Added an answer on May 29, 2026 at 5:57 am

    It’s telling you that it doesn’t recognize SparkController. It seems like the error could stem from the line above or maybe you need class SparkController; at the top of HelloWorldLayer.h.

    EDIT: Your problem is you are importing HelloWorldLayer.h in SparkController and SparkController.h in HelloWorldLayer. This will not work. You should import those in the implementation (.m) files instead and forward declare classes in the .h files.

    HelloWorldLayer.h:
    @class SparkController;

    HelloWorldLayer.m:
    #import "SparkController.h"

    SparkController.h:
    @class HelloWorldLayer;

    SparkController.m:
    #import "HelloWorldLayer.h"

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am doing a simple coin flipping experiment for class that involves flipping a
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.