在PC上运行的Cocos2d-x for XNA “Hello world”
2012-03-14 23:57
417 查看
编译好的DLL文件下载地址:http://download.csdn.net/detail/qy1213/4141611
1、新建项目
2、添加DLL引用
3、编写两个类AppDelegate.cs和HelloWorldScene.cs
程序运行结果:
1、新建项目
2、添加DLL引用
3、编写两个类AppDelegate.cs和HelloWorldScene.cs
public class AppDelegate : CCApplication { public AppDelegate(Game game, GraphicsDeviceManager graphics) : base(game, graphics) { CCApplication.sm_pSharedApplication = this; } public override bool initInstance() { return base.initInstance(); } public override bool applicationDidFinishLaunching() { CCDirector pDirector = CCDirector.sharedDirector(); pDirector.setOpenGLView(); pDirector.DisplayFPS=true; pDirector.animationInterval = 1.0 / 60; CCScene pScene = HelloCocos2dScene.scene(); pDirector.runWithScene(pScene); return true; } public override void applicationDidEnterBackground() { CCDirector.sharedDirector().pause(); } public override void applicationWillEnterForeground() { CCDirector.sharedDirector().resume(); } }
public class HelloCocos2dScene : CCLayer { public override bool init() { CCDirector.sharedDirector().deviceOrientation = ccDeviceOrientation.CCDeviceOrientationLandscapeLeft; if (!base.init()) { return false; } this.m_bIsTouchEnabled = true; CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage( "CloseNormal", "CloseSelected", this, new SEL_MenuHandler(menuCloseCallback) ); pCloseItem.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width - 20, 20); CCMenu pMenu = CCMenu.menuWithItems(pCloseItem); pMenu.position = new CCPoint(0, 0); this.addChild(pMenu, 1); CCLabelTTF pLabel = CCLabelTTF.labelWithString("Hello World", "Arial", 24); CCSize size = CCDirector.sharedDirector().getWinSize(); pLabel.position = new CCPoint(size.width / 2, size.height - 50); this.addChild(pLabel, 1); CCSprite pSprite = CCSprite.spriteWithFile("HelloWorld"); pSprite.position = new CCPoint(size.width/2, size.height/2); this.addChild(pSprite, 0); return true; } CCSprite pSprite; public static CCScene scene() { CCScene scene = CCScene.node(); CCLayer layer = HelloCocos2dScene.node(); scene.addChild(layer); return scene; } public static new CCLayer node() { HelloCocos2dScene ret = new HelloCocos2dScene(); if (ret.init()) { return ret; } else { ret = null; } return ret; } public virtual void menuCloseCallback(CCObject pSender) { CCDirector.sharedDirector().end(); CCApplication.sharedApplication().Game.Exit(); } public override void ccTouchesBegan(List<CCTouch> touches, CCEvent event_) { } }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; this.graphics.IsFullScreen = false; TargetElapsedTime = TimeSpan.FromTicks(333333); InactiveSleepTime = TimeSpan.FromSeconds(1); CCApplication application = new AppDelegate(this, graphics); this.Components.Add(application); }
程序运行结果:
相关文章推荐
- cocos2d-x for XNA
- Cocos2D-X for XNA游戏开发指南
- Cocos2d-X for XNA游戏引擎发布
- Cocos2d-html5 搭建开发环境,运行 Hello World,JetBrains IDE Support
- Cocos2d-html5 搭建开发环境,运行 Hello World,JetBrains IDE Support
- Cocos2d-html5 搭建开发环境,运行 Hello World,JetBrains IDE Support
- Tornado2.2 for pcPentium的安装和使用流程 pc上运行vxworks
- cocos2d-x for xna 地图编辑
- [Cocos2d-x]Mac下运行HelloCpp For Android
- Cocos2d-html5 搭建开发环境,运行 Hello World,JetBrains IDE Support
- Cocos2d-x 3.0 beta2 环境搭建-在安卓手机上运行Hello World
- cocos2d-xna for win8源代码轻松移植cocos-xna for wp游戏
- bochs for windows 运行hello world汇编程序,输出红字hello world
- cocos2d-x for xna 基于地图的碰撞检测和信息提示
- Cocos2d-js 学习笔记<一> 运行Hello World
- Cocos2D-X for XNA游戏开发指南
- (已解决)cocos2d-x 运行时xcode提示错误:"vtable for XXX", referenced from;
- cocos2d-x for xna实现人物不同方向行走
- Cocos2d-x for XNA:万丈高楼亦可不需平地起
- Chapter1-怎么在visual studio 2012上运行第一个cocos2d-x项目:Hello World!