Hi!
I am trying to get the touches example working in my game, but i can't.
The onEnter function is never called...
this is my code:
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"flecha.png" capacity:100];
[self addChild:mgr z:2 tag:kTagAtlasSpriteManager];
arrow = [[Arrow alloc] initWithPosition: 240 y:160 theGame: self];
and my object's init function:
-(id) initWithPosition: (int) x y:(int) y theGame:(GameLayer *) game
{
if (self = [super init])
{
state = kStateUngrabbed;
AtlasSpriteManager *mgr = (AtlasSpriteManager*) [game getChildByTag:kTagAtlasSpriteManager];
mySprite = [AtlasSprite spriteWithRect:CGRectMake(0,0,32, 32) spriteManager:mgr];
[mgr addChild: mySprite];
mySprite.position = ccp(x,y);
b2BodyDef bodyDef;
bodyDef.position.Set(x/PTM_RATIO, y/PTM_RATIO);
bodyDef.userData = mySprite;
body = game->world->CreateBody(&bodyDef);
b2PolygonDef shapeDef;
shapeDef.SetAsBox(.5f, .5f);//These are mid points for our 1m box
shapeDef.density = 1.0f;
shapeDef.friction = 0.3f;
body->CreateShape(&shapeDef);
body->SetMassFromShapes();
}
return (self);
}
I copied everything from the example except for the initialization of the object that contains the sprite...
But isn't onenter called when the node is added to the scene/manager?