LHSprite Reference


Class Methods

createWithFile

+ (LHSprite *)createWithFile
Parameters
filename

A path to image file, e.g., "scene1/monster.png"

folder

The folder containing the Cocos2d-x suffix folders. The folder must be added as reference in Xcode. If the suffix folders are added directly in the project this parammeter should be "".

prnt

A parent node. Must be in the LHScene hierarchy.

Return Value

An autoreleased sprite object. Eg:

INDIVIDUAL_IMAGES_FOLDER/ (added as reference in Xcode - has Blue icon)
   568/
       background.png
   hd/
       background.png
   ipad/
       background.png
   ipadhd/
       background.png

LHSprite* spr = LHSprite::createWithFile("background.png", "INDIVIDUAL_IMAGES_FOLDER/", this);
if(spr){
   spr->setAnchorPoint(Point(0,0));
   spr->setPosition(Point(0,0));
   spr->setLocalZOrder(-4);
}

Discussion

Creates a sprite with an image filename.

Declared In
LHSprite.h

createWithSpriteName

+ (LHSprite *)createWithSpriteName
Parameters
spriteName

A null terminated string which indicates the sprite frame name.

imageFile

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

folder

A null terminated 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)
   568/
       objects.plist
       objects.png
   hd/
       objects.plist
       objects.png
   ipad/
       objects.plist
       objects.png
   ipadhd/
       objects.plist
       objects.png

LHSprite* spr = LHSprite::createWithSpriteName("object_backpack", "objects.png", "DEMO_PUBLISH_FOLDER/", this->getGameWorld());
if(spr){
   spr->setPosition(Point(400,350));
}

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

Back to top

Copyright © VLADU BOGDAN DANIEL PFA.