LHSprite Reference

Inherits from
  • CCSprite
Conforms to
LHSprite.h

Overview

LHSprite class is used to load textured rectangles that are found in a level file.

Class Methods

createWithSpriteName:imageFile:folder:parent:

+ (instancetype)createWithSpriteName:(NSString *)spriteFrameName imageFile:(NSString *)imageFile folder:(NSString *)folder parent:(CCNode *)prnt
Parameters
spriteFrameName

A string which indicates the sprite frame name.

imageFile

A string which indicates the image file containing the sprite texture. This file will be used to look for the plist file.

folder

A string which indicates the folder that contains the image & plist file. The folder must be added as reference in Xcode - blue icon.

prnt

A parent node. Must be in the LHScene hierarchy.

Return Value

An autoreleased sprite object

Discussion

Creates a sprite with an sprite frame name using a sprite sheet name.

Eg:

DEMO_PUBLISH_FOLDER/ (added as reference in Xcode - has Blue icon)
objects-ipad.plist
objects-ipad.png
objects-ipadhd.plist
objects-ipadhd.png
objects-iphone5.plist
objects-iphone5.png
objects-iphone6.plist
objects-iphone6.png
objects-iphone6plus.plist
objects-iphone6plus.png
objects.plist
objects.png

LHSprite* sprite = [LHSprite createWithSpriteName:@"carBody"
                                           imageFile:@"carParts.png"
                                           folder:@"PUBLISH_FOLDER/"
                                           parent:[self gameWorldNode]];
if(sprite){
   [sprite setPosition:location];
}

Declared In
LHSprite.h

Instance Methods

imageFilePath

- (NSString *)imageFilePath
Discussion

Returns the sprite image file path.

Declared In
LHSprite.h

setSpriteFrameWithName:

- (void)setSpriteFrameWithName:(NSString *)spriteFrame
Parameters
spriteFrame

The name of the sprite texture rectangle as defined in the Sprite Packing Editor.

Discussion

Change the sprite texture rectangle with the a new texture rectangle defined by the sprite frame with a specific name.

Declared In
LHSprite.h

spriteFrameName

- (NSString *)spriteFrameName
Discussion

Returns the sprite frame name.

Declared In
LHSprite.h
Last updated: 2015-2-12

Back to top

Copyright © VLADU BOGDAN DANIEL PFA.