I need, with TouchMoved, scroll a large tilesmap atlas and i want move a player relative at portion of view that i see.
i move tilemap on touchmove.
-(id) init
{
if ((self=[super init]))
{
self.isTouchEnabled = YES;
TMXTiledMap *tilemap = [TMXTiledMap tiledMapWithTMXFile:@"orthogonal-test2.tmx"];
[self addChild:tilemap z:0 tag:kTagTileMap];
[tilemap reorderChild:[tilemap layerNamed:@"Layer 0"] z:1];
[tilemap reorderChild:[tilemap layerNamed:@"Layer 1"] z:3];
AtlasSpriteManager *mgr_player = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
[tilemap addChild:mgr_player z:2 tag:kTagPlayer];
mgr_player.position = ccp(tilemap.contentSize.width / 3, tilemap.contentSize.height / 3);
mgr_player.scale = 0.6f;
// animation
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager:mgr_player];
[mgr_player addChild:sprite];
sprite.anchorPoint = ccp(0.5, 0.1);
AtlasAnimation *animation = [AtlasAnimation animationWithName:@"dance" delay:0.2f];
for (int i = 0; i < 14; i++)
{
int x= i % 5;
int y= i / 5;
[animation addFrameWithRect:CGRectMake(x * 85, y * 121, 85, 121)];
}
id action = [Animate actionWithAnimation:animation];
id action2 = [RepeatForever actionWithAction:action];
[sprite runAction:action2];
}
return self;
}
The player is added to tilemap, if i scroll tilemap (move it) the location view touch (click) don't is realative a new portion of tilemap that i see.
Player move only in a fist portion view, when application is start.