Sprite (ELF)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.