Game Development Reference
In-Depth Information
[player updateVertexZ:tilePos tileMap:tileMap];
}
If you try this now, you'll see that the ninja player will hide behind walls, trees, and
other large objects, like a good ninja does.
Moving the Player, Tile by Tile
So far, the player (actually, the screen) moves faster the further away from the center
the screen is touched. The player also moves across the tiles freely, but he really should
be moving from tile to tile in only four directions. The IsoTilemap03 project changes
the control mechanism to one that allows you to move the player in one of the four al-
lowed directions as long as you keep a finger on the screen. The move direction de-
pends on where you touch the screen relative to the player.
This requires some additions to the TileMapLayer interface, shown in Listing 11-6 .
Listing 11-6. The TileMapLayer Class Interface
typedef enum
{
MoveDirectionNone = 0,
MoveDirectionUpperLeft,
MoveDirectionLowerLeft,
MoveDirectionUpperRight,
MoveDirectionLowerRight,
MAX_MoveDirections,
} EMoveDirection;
@class Player;
@interface TileMapLayer : CCLayer
{
CGPoint playableAreaMin, playableAreaMax;
Player* player;
CGPoint screenCenter;
CGRect upperLeft, lowerLeft, upperRight, lowerRight;
CGPoint moveOffsets[MAX_MoveDirections];
 
 
Search Nedrilad ::




Custom Search