Más contenido relacionado Similar a 09 creating windows phone game with cocos2d-xna (20) 09 creating windows phone game with cocos2d-xna6. Cocos2d-x for XNA"
Hello World
C# with XNA 50%
Windows Phone 7.5 工作量
http://download.cocos2d-x.org
MIT
License
开放下载 开源
10. Cocos2d-x for XNA与cocos2d-x关系"
class Engine: public API class API
{ {
public : virtual void
string language; addChild(CCNode*)=0;
string supportPlatforms; …
}; };
// language = “c++”
// supportPlatforms = “iOS Android …” // language = “c#”
class cocos2d-x: public Engine // supportPlatfroms = “windows
{ phone7”
public : class cocos2d-x_for_xna : public
virtual void addChild(CCNode*); Engine
}; {
public :
virtual void addChild(CCNode*);
};
12. 显示图片"
// c++
CCSprite *pSprite = CCSprite::spriteWithFile(“helloworld.png”);
pSprite->setPosition(ccp(100, 100));
addChild(pSprite);
// c#
CCSprite sprite = CCSprite.spriteWithFile(“helloworld”);
sprite.position = new CCPoint(100, 100);
addChild(sprite);
13. 动画效果"
// c++
CCMoveTo *moveTo = CCMoveTo::actionWithDuration(2, ccp(50, 50));
pSprite->runAction(moveTo);
// c#
CCMoveTo moveTo = CCMoveTo.actionWithDuration(2, new CCPoint(50, 50));
sprite.runAction(moveTo);
14. 粒子效果"
// c++
CCParticleSystem *particle = CCParticleFlower::node();
particle->setTexture(pSprite->getTexture());
particle->setPosition(ccp(100, 100));
addChild(particle);
// c#
CCParticleSystem particle = new CCParticleFlower();
particle.texture = sprite.texture;
particle.position = new CCPoint(100, 100);
addChild(particle);
15. 显示文本"
// c++
CCLabelTTF *pLabel = CCLabelTTF::labelWithString(“hello”, “Arial”, 20);
pLabel->setPosition(ccp(100, 100));
addChild(pLabel);
// c#
CCLabelTTF label = CCLabelTTF.labelWithString(“hello”, “Arial”, 20);
label.position = new CCPoint(100, 100);
addChild(label);
16. 添加菜单"
// c++
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(“bg.mp3”);
CCMenuItemLabel *pItemLabel = CCMenuItemLabel::itemWithLabel(“item”);
SimpleAudioEngine::sharedEngine()->playEffect(“effect.ogg”);
CCMenu *pMenu = CCMenu::menuWithItems(pItemLabel, NULL);
pMenu->setPosition(ccp(100, 100));
// c#
addChild(pMenu);
SimpleAudioEngine.sharedEngine().playBackgroundMusic(“bg”);
SimpleAudioEngine.sharedEngine().playEffect(“effect”);
// c#
CCMenuItemLabel itemLabel = CCMenuItemLabel.itemWithLabel(“item”);
CCMenu menu = CCMenu.menuWithItems(itemLabel);
menu.position = new CCPoint(100, 100);
addChild(menu);