cocos2d实例学习《learn cocos2d demos》

来源:互联网 发布:大数据和人工智能 编辑:程序博客网 时间:2024/06/04 19:56

中文版:

 

日期:2016113—>注意时间,版本升级很快,可能新的内容本文章就落后了! 

 

上次介绍了关于cocos2d的安装,今天来讲一下cocos2d官方给的Demos,基于cocos2d引擎中开发的开发图示。限于时间有限,生动的图示就不画了。大家自行脑补吧。(微笑)。

 

打开解压后的cocos2d文件,在build文件夹下可以找到三个“.sln”文件,其中两个分别对应于不同的windows 平台。第三个是普通的win32项目。

 

大家可以根据自己操作系统版本的不同来选择。在这里选择win32.sln。打开后的效果如图所示:选择cpp-empty-test.然后右键选择setup as Startupproject.(中文版本的vs应为设置为首选项)这点很关键,如果不进行这个设置的话,那么运行这个程序由于系统不知道从哪个.cpp文件开始,所以会一一编译,那么大概要等30-50分钟,才能编译完成。 所以最好设置。稍稍等一会,就能看到HelloWorld的Demo了。截图如下:


至于想修改里面的文字和图片;可以找到cpp-empty-test下的子项,classes文件,找到HelloWorldScene.cpp找到如下代码:

auto label =Label::createWithTTF("Hello World", "fonts/arial.ttf",TITLE_FONT_SIZE);


修改即可,改变图片也是在该文件中找到下面代码:

 auto sprite =Sprite::create("HelloWorld.png");


就可以查看做出自己的HelloWorld了。

 

如果想看更多实例。把cpp-tests设置为首选项,ctrl+F5运行一下即可。可以看到,很多实例。

欣赏一下就可以。不过在这里要说,如果你是Lua或者js开发,那么可以看看js-tests和Lua-tests。就到这里了,晚安!下一节,HelloWorld的具体组成和我们去编写开发什么?



ENGLISH VERSION:

 

The date is due to2016/11/2. Please pay attention to thetime to avoid the version of currentversion and the future.

 

Last time weintroduced how to install cocos2d, now wewill learn the Demos provided bycocos.org and the drafts of the produces indeveloping cocos2d.  For the vivid graphics, do it by yourself.(smile…)

 

 

After unzip thefile named cocos2d-x-3.13.1 , you can findthree file with the suffix “.sln” inthe file named build. The first two basedon different windows version. And thethird is the original project. You canchoose any of them based on your windowsversion. Here I choose win32.sln. waita while, you can see some projects inyour vs. choose cpp-empty-test then clickthe right mouse to set “setup asStartup project”(if your vs is C-Version, chosethe first chosen). It`s importantbecause you can save lots of time. Here is theprtSc:


If you want modifythe text and picture, you can find the” HelloWorldScene.cpp”  in this path“/cpp-empty-test/classes/HelloWorldScene.cpp”.Find codes like this:

auto label =Label::createWithTTF("HelloWorld", "fonts/arial.ttf",TITLE_FONT_SIZE);

Change to what youwant to show!

 

Also, Find codeslike this:

auto sprite=Sprite::create("HelloWorld.png");

you can displayany picture! ( but follow the suffix like“.png/.jpg…”)

 

For more demos,set cpp-tests as Startup Project , usectrl+F5, you can see many demos like thepicture.

And if you aremajor in Lua or Js , you can see thelua-tests or js-tests for more demos. Goodnight, next we will search fordetails about the uneasy Demos: HelloWorld 




0 0
原创粉丝点击