Hey,
So im having a lot of trouble with my animations im sure its just a stupid mistake by me but i just cant figure it out. What im trying to do is run an action either moving or idle. This is how i have it setup as right now:
.h file
AtlasAnimation *walking;
AtlasAnimation *idle;
Action *player1Walking;
Action *player2Walking;
Action *player3Walking;
Action *player1Idle;
Action *player2Idle;
Action *player3Idle;
and
.m file
-(void) loadSprites {
//Grab PlayerNames
NSString *play1name = [[GlobalDataManager sharedDataManager].players objectAtIndex:0];
// Create an Atlas Sprite Manager - that we will use for our sprites.
AtlasSpriteManager *managerplayer1 = [AtlasSpriteManager spriteManagerWithFile:[NSString stringWithFormat:@"%@Walking2.png", play1name] capacity:50];
[self addChild:managerplayer1 z:0 tag:player1SpriteManager];
//Create the actual Sprites
player1Sprite = [PlayerSprite spriteWithRect:CGRectMake(0, 0, 50, 38) spriteManager: managerplayer1];
//Make Some Animations
walking = [AtlasAnimation animationWithName:@"Moving" delay:0.1f];
for(int i=0;i<3;i++) {
int x= i % 3;
int y= i / 3;
[walking addFrameWithRect: CGRectMake(x*42, y*44, 42, 44) ];
}
idle = [AtlasAnimation animationWithName:@"Idle" delay:0.2f];
for(int i=0;i<1;i++) {
int x= i % 3;
int y= i / 3;
[idle addFrameWithRect: CGRectMake(x*42, y*44, 42, 44) ];
}
player1Walking = [Animate actionWithAnimation: walking];
player1Idle = [Animate actionWithAnimation: idle];
//Add the sprites to the managers
[managerplayer1 addChild:player1Sprite];
//Place the sprites on the screen
player1Sprite.position = ccp(100, 100);
}
-(void) playerMoving {
NSArray * mySprites = [PlayerSprite allPlayerSprites];
NSUInteger i, count = [mySprites count];
for (i = 0; i < count; i++) {
PlayerSprite * obj = (PlayerSprite *)[mySprites objectAtIndex:i];
if(obj.canThrow) {
if( CGPointEqualToPoint(obj.position, endPosition)) {
NSLog(@"Not Moving");
[obj runAction:[RepeatForever actionWithAction: player1Idle]];
} else {
NSLog(@"Moving");
[obj runAction:[RepeatForever actionWithAction: player1Walking]];
}
}
}
}
Im getting the warning:
warning passing argument 1 of 'actionWithAction' from distinct Objective-C type
Also is there an easy way to check if a player is moving or not. This method works but i have already found some problems with it.
Thanks
-Lars