Can't create the child class of CCSprite

Can't create the child class of CCSprite
0.0 0


I want to create a new class which is a child class of CCSprite. But it doesn’t work.

It got the error CCBullet does not name a type

Please take a look and tell me some your ideas to solve my problems. Thanks.


#ifndef __GameplayScene_H__
#define __GameplayScene_H__

#include "cocos2d.h"
#include "common/Define.h"

#include "../../Box2DTestBed/GLES-Render.h"
#include "Box2D/Box2D.h"
#include "chipmunk.h"


class CCBullet : public cocos2d::CCSprite
    static CCBullet* create(int bulletID, const char *filePath);
    int mBulletID; 
    float mSpeed;
    float mStrength; 
    float mPushBack; 
    float mCritical; 
    float mFanShoot; 
    float mSpread;
    float mAngle;



#include "common/Define.h"
using namespace cocos2d;
using namespace cocos2d::extension;

CCBullet* CCBullet::create(int bulletID, const char *filePath){
    CCBullet *pobSprite = new CCSprite();
    if (pobSprite && pobSprite->initWithFile(filePath))
        pobSprite->mBulletID = bulletID;    
        pobSprite->mAngle = 0;
        pobSprite->mSpeed = 0;
        pobSprite->mStrength = 0;
        pobSprite->mPushBack = 0;
        pobSprite->mCritical = 0;
        pobSprite->mFanShoot = 0;
        pobSprite->mSpread = 0;
        return pobSprite;
    return NULL;


change “CCBullet *pobSprite = new CCSprite();” to “CCBullet *pobSprite = new CCBullet();”


@wpstu Thank for your quick reply. I’ll try. One more question. How can I get properties of CCBullet object like speed, angle (I updated my questions)?


@lolyoshi i think this is not a problem of cocos2d-x but a problem of c++,you can get help through google/baidu.


@wpstu I tried but it still causes the error :frowning: