Appendix A: Types & Functions Document

Previous: - Next: Appendix B: About Tile GIDs

TilemapKit defines additional types and constants used throughout the API.

These are C functions, typedefs and preprocessor macros. That’s why they aren’t picked up by the automated reference documentation and are documented here instead.

Types

Name                    Type/Value
-------------------------------------------
TKTileGID               uint32_t
TKTerrainCorner         uint16_t

TKPoint                 NSInteger: {x, y}
TKSize                  NSInteger: {width, height}
TKRect                  {TKPoint origin, TKSize size}

TKScene                 alias for: SKScene / CCScene
TKNode                  alias for: SKNode / CCNode
TK*Node                 additional node aliases, following SpriteKit API naming schemes
TKTexture               alias for: TKTexture / CCSpriteFrame
TKColor                 alias for: SKColor / CCColor
TKAction                alias for: SKAction / CCAction
TKActionFactory         alias for: SKAction / TKActionFactory (wrapper class)
TKPhysicsBody           alias for: SKPhysicsBody / CCPhysicsBody

TKEvent                 alias for: UIEvent / NSEvent
TKView                  alias for: UIView / NSView
TKTouch                 alias for: UITouch or NSTouch / CCTouch
TKTouchEvent            alias for: - / CCTouchEvent

Constants

Name                    Type/Value
-------------------------------------------
TKTileGIDEmpty          ( 0)
TKTileGIDInvalid        (-1) equals UINT32_MAX

TKRepeatCounfInfinit    e   (-1)

TKPointZero             (0,0)
TKPointInvalid          (NSIntegerMin,NSIntegerMin)
TKSizeZero              (0,0)
TKRectZero              (0,0,0,0)

TK_PI_180               (PI / 180)
TK_180_PI               (180 / PI)

Functions

Radians/Degrees Conversion

TK_DEG2RAD(degrees)     convert degrees to radians
TK_RAD2DEG(radians)     convert radians to degrees

TKPoint Conversion

TKPoint TKPointMake(int32_t x, int32_t y);
CGPoint CGPointFromTKPoint(TKPoint point);
TKPoint TKPointFromCGPoint(CGPoint point);

// rounds CGPoint to nearest integer before converting
TKPoint TKPointFromRoundedCGPoint(CGPoint point);

// creates CGPoint from its string representation: "1.2, 3.4"
CGPoint tk_pointForString(NSString* point);

TKSize Conversion

TKSize TKSizeMake(int32_t width, int32_t height);
CGSize CGSizeFromTKSize(TKSize size);
TKSize TKSizeFromCGSize(CGSize size);

// rounds CGSize to nearest integer before converting
TKSize TKSizeFromRoundedCGSize(CGSize size);

TKRect Conversion

TKRect TKRectMake(NSInteger x, NSInteger y, NSInteger width, NSInteger height);
CGRect CGRectFromTKRect(TKRect rect);

Resource Functions

// returns file if the file exists
// otherwise runs it through engine's resource file locator:
//  SpriteKit: NSBundle pathForResource:
//  Cocos2D: CCFileUtils fullPathForFilename:
NSString* tk_getPathForFile(NSString* file);

// creates a TKColor from the given RGB string, using HTML color format:
// "#rrggbb" or "rrggbb" - for example: "#EAEAEA" or "1EE708"
TKColor* tk_colorWithString(NSString* string);

Engine Compatibility Functions

CGFloat tk_getContentScaleFactor(TKNode* node);
TKView* tk_getView(TKNode* node);
CGSize tk_getViewSize(TKNode* node);

Previous: - Next: Appendix B: About Tile GIDs