아이소 메트릭 타일 맵의 특정 위치에서 스프라이트에 애니메이션을 적용하고 싶습니다. 주어진 레이어에서 스프라이트를 애니메이트 할 수는 있지만, 타일 맵에서 스프라이트를 생성 할 때는 그렇지 못합니다. 예를 들어, 잘 작품을 다음타일 맵에서 스프라이트 애니메이션하기
// make a frame cache
CCSpriteFrameCache *frameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
[frameCache addSpriteFramesWithFile:@"spellanim.plist" textureFile:@"spellanim.pvr.ccz"];
// create a sprite
CCSprite *effectSprite = [CCSprite spriteWithSpriteFrameName:@"spell_strength__33.png"];
// set sprite at center of screen
CGSize screenSize = [[CCDirector sharedDirector] winSize];
effectSprite.position = CGPointMake(screenSize.width/2, screenSize.height/2);
// create animation using an animation helper (since animationWithName:delay:frames: will be deprecated)
CCAnimation *animation = [CCAnimation animationWithFrame:@"spell_strength__" frameCount:13 delay:0.3f startAt:33];
CCAnimate *animate = [CCAnimate actionWithAnimation:animation];
// run animation on sprite
[effectSprite runAction:animate];
// add sprite as a child of the layer
[self addChild:effectSprite];
을 지금 작동하지 않습니다 다음, 나는 그것이 : 타일 맵 작업 (나는 CCSprite는 SetTexture에서 어설 션 오류를 얻을 방법과 관련이있다 가정
// add one to x to offset the spell animation from the player
CGPoint tileCoord = CGPointMake(player.entityTileCoordinate.x + 1, player.entityTileCoordinate.y);
// get the effects layer from the tile map
CCTMXTiledMap *tileMap = (CCTMXTiledMap *)[[TileMapLayer sharedTileMapLayer] getChildByTag:TileMapNode];
CCTMXLayer *effectsLayer = [tileMap layerNamed:@"Effects"];
// get a sprite from the effects layer
CCSprite *effectSprite = [effectsLayer tileAt:CGPointMake(0, 0)];
// move the sprite to the desired location (this works just fine)
CGPoint pointPixel = [effectsLayer positionAt:tileCoord];
[effectSprite runAction:[CCMoveTo actionWithDuration:0.0f position:pointPixel]];
// now animate the sprite
CCSpriteFrameCache *frameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
[frameCache addSpriteFramesWithFile:@"spellanim.plist" textureFile:@"spellanim.pvr.ccz"];
CCAnimation *animation = [CCAnimation animationWithFrame:@"spell_strength__" frameCount:13 delay:0.3f startAt:33];
CCAnimate *animate = [CCAnimate actionWithAnimation:animation];
[effectSprite runAction:animate];
내 생각 엔 애니메이션 스프라이트가 타일 맵의 해당 레이어에 설정된 타일의 일부가 아니기 때문입니다. 이 애니메이션 스프라이트를 해당 레이어에서 그리는 데 사용되는 캐시에 동적으로 추가하는 방법이 있습니까 (기본적으로 런타임시 타일 세트 수정)? 나중에 수정 된 타일 세트에서이 스프라이트를 제거 할 수 있습니까? 런타임에 타일셋을 수정할 때 여전히 1024x1024 제한이 있습니까?
하루가 끝날 무렵 타일 맵에서 한 타일에서 다른 타일로 움직이는 애니메이션 스프라이트를 만들 수 있기를 원하지만 가장 효율적인 방법으로이를 수행하는 방법을 모르겠습니다. 타일 맵에 효과 레이어가 있고 타일이 모든 맞춤법 애니메이션으로 설정되어있는 경우 (특히 1024x1024에 맞지 않는 경우), 애니메이션을 어셈블하면 타일 GID 업데이트가 연쇄 적으로 연결되어 효과가 타일지도.
레이어가 타일 맵의 일부가 아닌 경우 내가 할 수있는 작업을 알고 있습니다. 화면 좌표를 사용하여 스프라이트를 움직이고 움직일 수 있지만 타일 좌표를 알고있을 때 화면 좌표로 변환합니다 (타일이 화면에 보이더라도) 지금까지 내 이해를 피했다. 스크린에서 실제로 볼 수있는 타일을 어떻게 결정합니까? 그러면 가시적 인 타일의 화면에서 픽셀 좌표는 무엇입니까?
이 프로세스를 진행하는 방법에 대한 의견을 보내 주시면 감사하겠습니다.