在PC上运行的Cocos2d-x for XNA “Hello world”
来源:互联网 发布:阿里云有人工客服吗 编辑:程序博客网 时间:2024/04/29 03:05
编译好的DLL文件下载地址:http://download.csdn.net/detail/qy1213/4141611
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); }
程序运行结果:
- 在PC上运行的Cocos2d-x for XNA “Hello world”
- Chapter1-怎么在visual studio 2012上运行第一个cocos2d-x项目:Hello World!
- Cocos2d-x 3.0 beta2 环境搭建-在安卓手机上运行Hello World
- cocos2d-x 的安装以及hello world
- “Hello World”在Linux系统上的运行过程
- Cocos2d-X for XNA游戏引擎发布
- Cocos2D-X for XNA游戏开发指南
- Cocos2D-X for XNA游戏开发指南
- 在Android平台上运行Cocos2D-x的HelloWorld
- Mybatis在Maven上的 hello world
- Cocos2D-x for XNA类解析(2): CCDirector(上)
- 在Predix上运行Flask版Hello World
- 在 mac os 上运行 kotlin native 的第一个程序:hello world
- Cocos2d-x--"Hello World"深入分析
- cocos2d-x教程1 hello world
- cocos2d-x之浅析Hello World
- cocos2d-x-3.3rc2-001-hello-world
- 【Cocos2d-x 游戏开发】 1 --- Hello World
- CAN总线学习心得:zlg关于can帖子汇总【转】【强烈推荐】
- oracle集合运算
- 数据结构 绪论
- Learning Opencv第三章(1)
- java多线程实现生产者/消费者同步
- 在PC上运行的Cocos2d-x for XNA “Hello world”
- 开始学学java吧
- 谁来拯救云计算
- 当你走不下去的时候
- Mysql 性能
- hardware design
- 让男人又恨又爱加倍疼惜的十八种撒娇方式
- 人生不能等待的三件事
- 实例解析linux内核I2C体系结构(2) [嵌入式]