CCPoint LayerOffset(CCPoint offsetInTileCoords) { CCPoint offsetInNodespace = CCPoint.Zero; switch (MapType) { case CCTileMapType.Ortho: offsetInNodespace = new CCPoint(offsetInTileCoords.X * TileTexelSize.Width, -offsetInTileCoords.Y * TileTexelSize.Height); break; case CCTileMapType.Iso: offsetInNodespace = new CCPoint((TileTexelSize.Width / 2) * (offsetInTileCoords.X - offsetInTileCoords.Y), (TileTexelSize.Height / 2) * (-offsetInTileCoords.X - offsetInTileCoords.Y)); break; case CCTileMapType.Staggered: float diffX = 0; if ((int)offsetInTileCoords.Y % 2 == 1) { diffX = TileTexelSize.Width / 2; } offsetInNodespace = new CCPoint(offsetInTileCoords.X * TileTexelSize.Width + diffX, -offsetInTileCoords.Y * TileTexelSize.Height / 2); break; case CCTileMapType.Hex: Debug.Assert(offsetInTileCoords.Equals(CCPoint.Zero), "offset for hexagonal map not implemented yet"); break; } offsetInNodespace *= CCTileMapLayer.DefaultTexelToContentSizeRatios; return(offsetInNodespace); }
public override void Visit() { CCPoint pos = AbsolutePosition; if (!pos.Equals(lastPosition)) { foreach (CCPointObject point in ParallaxArray) { point.Child.Position = -pos + (pos * point.Ratio) + point.Offset; } lastPosition = pos; } base.Visit(); }
public override void Visit(ref CCAffineTransform parentWorldTransform) { CCPoint pos = AbsolutePosition; if (!pos.Equals(lastPosition)) { foreach (CCPointObject point in ParallaxArray) { point.Child.Position = -pos + (pos * point.Ratio) + point.Offset; } lastPosition = pos; } base.Visit(ref parentWorldTransform); }
CCPoint ApplyLayerOffset(CCPoint tileCoord) { CCPoint ret = CCPoint.Zero; switch (LayerOrientation) { case CCTMXOrientation.Ortho: ret = new CCPoint(tileCoord.X * MapTileSize.Width, -tileCoord.Y * MapTileSize.Height); break; case CCTMXOrientation.Iso: ret = new CCPoint((MapTileSize.Width / 2) * (tileCoord.X - tileCoord.Y), (MapTileSize.Height / 2) * (-tileCoord.X - tileCoord.Y)); break; case CCTMXOrientation.Hex: Debug.Assert(tileCoord.Equals(CCPoint.Zero), "offset for hexagonal map not implemented yet"); break; } return(ret); }
public bool Equals(CCRect rect) { return(Origin.Equals(rect.Origin) && Size.Equals(rect.Size)); }