1. Sound effects
Introducing Header Files
#include "simpleAudioEngine.h"
Name space
using namespace Cocosdenshion;
1 //Create a background2Size winsize = Director::getinstance ()getwinsize ();3Spritetest = Sprite::create ("Bg.png");4Spritetest->setposition (VEC2 (winsize.width/2, winsize.height/2));5 This-AddChild (spritetest);6 7 //8Menuitemsprite *itemsprite = menuitemsprite::create (Sprite::create ("1.png"), Sprite::create ("8.png"), [&] (REF *Spander) {9Cclog ("Click the button");Ten //Play Sound OneSimpleaudioengine::getinstance ()->playeffect ("Bg.mp3"); A }); -Itemsprite->setposition (VEC2 (winsize.width/2, -)); - theMenu *menu =menu::create (Itemsprite, NULL); -Menu->setposition (VEC2 ()); - This-addChild (menu); - + //Play background music -Simpleaudioengine::getinstance ()->playbackgroundmusic ("Bg.mp3",true); + return true; A at //Pre-load sound (load not play only) -Simpleaudioengine::getinstance ()->preloadeffect ("Bg.mp3");
2. Particle system
There's a particle design tool to customize particle effects
1 particlefire *ex = particlefire::create (); 2 ex->setposition (VEC2); 3 this->addchild (ex);
3. Data storage
1 //Storage2Userdefault::getinstance ()->setintegerforkey ("HP",123);3Userdefault::getinstance ()flush ();4 5 //Get6 intHP = Userdefault::getinstance ()->getintegerforkey ("HP");7Cclog ("hp=%d", HP);
COCOS2DX Sound Particle data storage