game crashed on running

i continue my ported from http://www.raywenderlich.com/4787/how-to-make-a-catapult-shooting-game-with-cocos2d-and-box2d-part-2 (i already done the part 1).
and i use clawoo ported from cocos2d-x ver 1 (i use cocos2dx ver 2) for reference

the game crashed on createTarget and createTargets
Code on HelloWorldScene.cpp

void HelloWorld::createTargets()
{
    targets.clear();
    enemies.clear();

    // First block
    this->createTarget("brick_2.png", CCPointMake(675.0, FLOOR_HEIGHT), 0.0f, false, false, false);
    this->createTarget("brick_1.png", CCPointMake(741.0, FLOOR_HEIGHT), 0.0f, false, false, false);
    this->createTarget("brick_1.png", CCPointMake(741.0, FLOOR_HEIGHT+23.0f), 0.0f, false, false, false);
    this->createTarget("brick_3.png", CCPointMake(672.0, FLOOR_HEIGHT+46.0f), 0.0f, false, false, false);
    this->createTarget("brick_1.png", CCPointMake(707.0, FLOOR_HEIGHT+58.0f), 0.0f, false, false, false);
    this->createTarget("brick_1.png", CCPointMake(707.0, FLOOR_HEIGHT+81.0f), 0.0f, false, false, false);

    this->createTarget("head_dog.png", CCPointMake(702.0, FLOOR_HEIGHT), 0.0f, true, false, true);
    this->createTarget("head_cat.png", CCPointMake(680.0, FLOOR_HEIGHT+58.0f), 0.0f, true, false, true);
    this->createTarget("head_dog.png", CCPointMake(740.0, FLOOR_HEIGHT+58.0f), 0.0f, true, false, true);

    // 2 bricks at the right of the first block
    this->createTarget("brick_2.png", CCPointMake(770.0, FLOOR_HEIGHT), 0.0f, false, false, false);
    this->createTarget("brick_2.png", CCPointMake(770.0, FLOOR_HEIGHT+46.0f), 0.0f, false, false, false);

    // The dog between the blocks
    this->createTarget("head_dog.png", CCPointMake(830.0, FLOOR_HEIGHT), 0.0f, true, false, true);

    // Second block
    this->createTarget("brick_platform.png", CCPointMake(839.0, FLOOR_HEIGHT), 0.0f, false, true, false);
    this->createTarget("brick_2.png", CCPointMake(854.0, FLOOR_HEIGHT+28.0f), 0.0f, false, false, false);
    this->createTarget("brick_2.png", CCPointMake(854.0, FLOOR_HEIGHT+28.0f+46.0f), 0.0f, false, false, false);
    this->createTarget("head_cat.png", CCPointMake(881.0, FLOOR_HEIGHT+28.0f), 0.0f, true, false, true);
    this->createTarget("brick_2.png", CCPointMake(909.0, FLOOR_HEIGHT+28.0f), 0.0f, false, false, false);
    this->createTarget("brick_1.png", CCPointMake(909.0, FLOOR_HEIGHT+28.0f+46.0f), 0.0f, false, false, false);
    this->createTarget("brick_1.png", CCPointMake(909.0, FLOOR_HEIGHT+28.0f+46.0f+23.0f), 0.0f, false, false, false);
    this->createTarget("brick_2.png", CCPointMake(882.0, FLOOR_HEIGHT+108.0f), 90.0f, false, false, false);
}

void HelloWorld::createTarget(const char *imageName, CCPoint position, float rotation, bool isCircle, bool isStatic, bool isEnemy)
{
    CCSprite *sprite = CCSprite::create(imageName);
    this->addChild(sprite, 1);

    b2BodyDef bodyDef;
    bodyDef.type = isStatic?b2_staticBody:b2_dynamicBody;
    bodyDef.position.Set((position.x+sprite->getContentSize().width/2.0f)/PTM_RATIO,
                         (position.y+sprite->getContentSize().height/2.0f)/PTM_RATIO);
    bodyDef.angle = CC_DEGREES_TO_RADIANS(rotation);
    bodyDef.userData = sprite;
    b2Body *body = world->CreateBody(&bodyDef);

    b2FixtureDef boxDef;
    if (isCircle == true)
    {
        b2CircleShape circle;
        circle.m_radius = sprite->getContentSize().width/2.0f/PTM_RATIO;
        boxDef.shape = &circle;
    }
    else
    {
        b2PolygonShape box;
        box.SetAsBox(sprite->getContentSize().width/2.0f/PTM_RATIO, sprite->getContentSize().height/2.0f/PTM_RATIO);
        boxDef.shape = &box;
    }

    if (isEnemy == true)
    {
        boxDef.userData = (void*)1;
        enemies.push_back(body);
    }

    boxDef.density = 0.5f;
    body->CreateFixture(&boxDef);

    targets.push_back(body);

}

and from the HelloWorldScene.h

 void createTargets();
    void createTarget(const char *imageName,
                      cocos2d::CCPoint position,
                      float rotation,
                      bool isCircle,
                      bool isStatic,
                      bool isEnemy);

private:
    std::vector bullets;
    std::vector targets;
    std::vector enemies;

it show no error when compiling but when i run it on device (eq android) it crashed. it something wrong with the code?

Hm, is the app able to find the resources like ‘brick_2.png’?

/miro/

yeah, its able… im still getting crashed on the game….

Is your class derived from any base class like CCLayer?
And if so, do you have an init() class function where you are calling the init() of the base class?

/miro/

El Miro wrote:

Is your class derived from any base class like CCLayer?
And if so, do you have an init() class function where you are calling the init() of the base class?
>
/miro/

yes… i call the base init from this code

CCScene* HelloWorld::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();

    // add layer as a child to scene
    CCLayer* layer = new HelloWorld();
    scene->addChild(layer);
    layer->release();

    return scene;
}

and on HelloWorld::HelloWorld i called the init class

HelloWorld::HelloWorld()
{
    setTouchEnabled( true );
    // init physics
    this->initPhysics();

    schedule(schedule_selector(HelloWorld::update));
}

i think ill put the code on git later… i dunno how to solve it .