标签:
1.音效
引入头文件
#include "simpleAudioEngine.h"
命名空间
using namespace CocosDenshion;
1 //创建一个背景 2 Size winSize = Director::getInstance()->getWinSize(); 3 spriteTest = Sprite::create("bg.png"); 4 spriteTest->setPosition(Vec2(winSize.width/2,winSize.height/2)); 5 this->addChild(spriteTest); 6 7 // 8 MenuItemSprite *itemSprite = MenuItemSprite::create(Sprite::create("1.png"), Sprite::create("8.png"), [&](Ref *spander){ 9 CCLOG("点击了按钮"); 10 //播放音效 11 SimpleAudioEngine::getInstance()->playEffect("bg.mp3"); 12 }); 13 itemSprite->setPosition(Vec2(winSize.width/2,100)); 14 15 Menu *menu = Menu::create(itemSprite, NULL); 16 menu->setPosition(Vec2()); 17 this->addChild(menu); 18 19 //播放背景音乐 20 SimpleAudioEngine::getInstance()->playBackgroundMusic("bg.mp3",true); 21 return true; 22 23 //提前加载音效(只加载不播放) 24 SimpleAudioEngine::getInstance()->preloadEffect("bg.mp3");
2.粒子系统
有个particle design 工具自定义粒子效果
1 ParticleFire *ex = ParticleFire::create(); 2 ex->setPosition(Vec2(320, 240)); 3 this->addChild(ex);
3.数据存储
1 //存储 2 UserDefault::getInstance()->setIntegerForKey("hp", 123); 3 UserDefault::getInstance()->flush(); 4 5 //获取 6 int HP = UserDefault::getInstance()->getIntegerForKey("hp"); 7 CCLOG("HP=%d",HP);
标签:
原文地址:http://www.cnblogs.com/wanyongjian/p/5094547.html