COCOS2DX Sound Particle data storage

Source: Internet
Author: User
Tags addchild

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

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.