The first game of Cocos2d_android

Source: Internet
Author: User

According to the previous article. Create a good cocos2d--android development environment

First on


The code that implements the effect:

Package Com.cn.firstgame;import Org.cocos2d.layers.ccscene;import Org.cocos2d.nodes.ccdirector;import Org.cocos2d.opengl.ccglsurfaceview;import Android.app.activity;import Android.os.bundle;import Android.view.Menu; public class Mainactivity extends Activity {//CC engine will draw the image in the Viewprivate ccglsurfaceview view; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); View=new Ccglsurfaceview (this); Setcontentview (view);//Get Director Object Ccdirector director=ccdirector.shareddirector ();/*** Set game Properties */director.attachinview (view);d Irector.setdisplayfps (True);d irector.setanimationinterval (1.0F/30);// Generate the game Scene object Ccscene Scene=ccscene.node ();//Generate Game Scene object Gamelayer layer=new gamelayer ();//Add Scene object to scene scene.addchild (layer) ;//perform scene director.runwithscene;} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.main, menu); return true;}}
Package Com.cn.firstgame;import Org.cocos2d.layers.cclayer;public Class Gamelayer extends Cclayer {public Gamelayer () {        }}


The first game of Cocos2d_android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.