Used as a refresher for later use.
1#include"ScenceScend.h"2 3ccscene*Scencescend::scene ()4 {5ccscene* s =ccscene::create ();6scencescend* layer =scencescend::create ();7S->addChild (layer);8 returns;9 Ten } One BOOLScencescend::init () A { - cclayer::init (); - //1. Create sprites directly from files the //ccsprite* sprite = Ccsprite::create (); - //ccsprite* sprite = ccsprite::create (filename,ccrect); - //ccsprite* sprite = ccsprite::create (filename); - + - //2. Create Sprites with textures + A //cctexture2d* texture = Cctexturecache::sharedtexturecache ()->addimage ("filename"); at //ccsprite* sprite = ccsprite::createwithtexture (texture); - //ccsprite* sprite = ccsprite::createwithtexture (texture,ccrect), also desirable picture local - //AddChild (sprite); - //3 creating with Sprite frames - /* - ccsize size = Ccdirector::shareddirector ()->getwinsize (); in - cctexture2d* texture = Cctexturecache::sharedtexturecache ()->addimage ("Helloworld.png"); to ccsize size2 = Texture->getcontentsize (); + ccspriteframe* frame = - ccspriteframe::createwithtexture (texture, Ccrectmake (SIZE2.HEIGHT/4, SIZE2.WIDTH/4, SIZE2.WIDTH/2, Size2 . Width/2)); the ccsprite* sprite = Ccsprite::createwithspriteframe (frame); * sprite->setposition (SIZE.WIDTH/2,SIZE.HEIGHT/2); $ AddChild (sprite);Panax Notoginseng */ - the //4. Create Sprites from the sprite frame cache + ACcsize size = Ccdirector::getinstance ()getwinsize (); the //cctexture2d Map Class +cctexture2d* texture = Cctexturecache::sharedtexturecache ()->addimage ("Helloworld.png"); -Ccsize size2 = texture->getcontentsize (); $ccspriteframe* frame = $Ccspriteframe::createwithtexture (Texture, ccrectmake (size2.height/4, Size2.width/4, Size2.width/2, Size2.width/2)); -Ccspriteframecache::sharedspriteframecache ()->addspriteframe (frame,"HXL"); -ccsprite* Sprite = Ccsprite::createwithspriteframename ("HXL"); theSprite->setposition (Size.width/2, Size.Height/2); - AddChild (sprite);Wuyi the /* - //Invokes the initialization of the parent class. So here is the subclass method that overrides the parent class. Wu cclayer::init (); - Cclabelttf *label = cclabelttf::create ("Hxltom", "Arial",); About label->setposition (Ccpoint (100,200)); $ addChild (label); - */ - - return true; A}
Sprite (ELF)