ハイ、
RPGゲームの開発を開始しました。私は、CCLayerPanZoom に配置した Isometric タイル マップを使用します。ここで、タイル マップに意地悪を配置したいと思います。クリックすると、マップ上で新しいスプライトが配置されている場所の位置がずれます。なんで?レイヤー間に滑りはありますか?新しいスプライトを配置したいマップ上の場所にクリック位置が対応するように、マップをズームレイヤーにアタッチする方法はありますか。
助けてください。
これが私の init() です。それを見たい人は、Xcode プロジェクトを含む zip を見てください。Kobold2D プロジェクトです。同じプロジェクトがありますが、CCLayerPanZoom レイヤーはありません。ポジショニングは完璧に機能しています。重要な注意: マップをドラッグして、左端が正確に iPad シミュレーターの左側の境界にくるようにすると、タイルの配置はほぼ問題ありません。タイルはほぼ適切な場所に配置されます。
- (id) init
{
if ((self = [super init]))
{
//touches enables
self.isTouchEnabled = YES;
//instantiate the PanZoomLayer
panZoomLayer = [CCLayerPanZoom node];
//seting poperties for the pan zoom layer
panZoomLayer.maxScale = 1.0f;
panZoomLayer.minScale = 0.2f;
panZoomLayer.maxSpeed = 100.0f;
panZoomLayer.maxTouchDistanceToClick = 1000.0f;
panZoomLayer.panBoundsRect = CGRectNull;
panZoomLayer.mode = kCCLayerPanZoomModeSheet;
//add the zoom layer to the CCLayer
[self addChild: panZoomLayer z:-1];
//if I uncoment this it thros me an error by ccTouchesEnded
//It has to be commented like this
//panZoomLayer.delegate = self;
self.map = [CCTMXTiledMap tiledMapWithTMXFile:@"isometric-no-offset.tmx"];
_map.anchorPoint = ccp(0,0);
_map.scale = CC_CONTENT_SCALE_FACTOR();
layer = [_map layerNamed:@"Ground"];
layer.visible = YES;
[panZoomLayer addChild: _map
z :-1
tag:kTileMapTag];
// create and initialize a Label
CCLabelTTF *label = [CCLabelTTF labelWithString: @"Zooming and scroling Demo"
fontName: @"Marker Felt"
fontSize: 30];
label.scale = 0.7f; //< to be visible on iPod Touch screen.
label.color = ccBLUE;
// add the label as a child to this Layer
[panZoomLayer addChild: label
z: 1
tag:kLabelTag];
_player = [CCSprite spriteWithFile:@"ninja.png"];
//map size
mapHeight = _map.contentSize.height;
mapWidth = _map.contentSize.width;
//screen size
CGSize screenSize = [[CCDirector sharedDirector] winSize];
screenCenter = CGPointMake(screenSize.width / 2, screenSize.height / 2);
//Hide/Show character
[_player setVisible:YES];
_player.position = ccp(300, 400);
[panZoomLayer addChild:_player z:2];
//dot initialization
self.dot = [CCSprite spriteWithFile:@"d2.png"];
//_dot. position = ccp(200,200);
[_map addChild:dot z:3];
panZoomLayer.mode = kCCLayerPanZoomModeSheet;
panZoomLayer.minScale = 0.6f;
panZoomLayer.maxScale = 2.0f;
panZoomLayer.rubberEffectRatio = 1.1f;
//test different scren reshapes
//the zooming and scroling works also without any of the following methods
//simple. until now the most convenient
[self updateForScreenReshape1];
//ruber. means center on screen. zoom out more in as previous
//[self updateForScreenReshape2];
//with zones. zoom out more and in less
//[self updateForScreenReshape3];
}
return self;
gBoy Baby ハッカー
投稿: 8 参加: 2012 年 5 月 10 日 (木) 19:26 感謝された: 0 回 感謝された: 0 回