Cocos2d-android-1 Source Detailed: 23.tilemaptest1

Source: Internet
Author: User

Package org.cocos2d.tests;

Import Org.cocos2d.actions.base.CCRepeatForever;

Import Org.cocos2d.actions.interval.CCMoveBy;

Import org.cocos2d.actions.interval.CCSequence;

Import Org.cocos2d.layers.CCLayer;

Import Org.cocos2d.layers.CCScene;

Import Org.cocos2d.layers.CCTMXTiledMap;

Import Org.cocos2d.nodes.CCDirector;

Import Org.cocos2d.nodes.CCNode;

Import Org.cocos2d.nodes.CCSprite;

Import Org.cocos2d.opengl.CCGLSurfaceView;

Import Org.cocos2d.types.CGPoint;

Import android.app.Activity;

Import Android.os.Bundle;

public class TileMapTest1 extends Activity {

public static final String Log_tag = TileMapTest.class.getSimpleName ();//Get the name of the class, if many return many

Private Ccglsurfaceview Mglsurfaceview;

@Override

protected void OnCreate (Bundle savedinstancestate) {

Super.oncreate (savedinstancestate);

Mglsurfaceview = new Ccglsurfaceview (this);//materialized view

Setcontentview (Mglsurfaceview);//Load view

Ccdirector.shareddirector (). Attachinview (Mglsurfaceview);//Additional Open Graphics language view

Ccdirector.shareddirector (). Setlandscape (false);//Set view mode

Ccdirector.shareddirector (). Setdisplayfps (True);

Ccdirector.shareddirector (). Setanimationinterval (1.0F/30);

Ccscene scene = Ccscene.node ();//Necessary construction

Scene.addchild (New Tmxisozorder ());//Sub-class belonging to next

Ccdirector.shareddirector (). Runwithscene (Scene);

}

public static final int ktagtilemap = 1;

Static Class Tmxisozorder extends Cclayer {//1

Ccsprite tamara;//Elf

Public Tmxisozorder () {

Super ();

Cctmxtiledmap map = Cctmxtiledmap.tiledmap ("ISO-TEST-ZORDER.TMX");//Create Maps

AddChild (map, 0, Ktagtilemap);//Add sub-class

Map.setposition ( -1000,-50);//Set point

Tamara = Ccsprite.sprite ("Grossinis_sister1.png");//Create Sprite

int z = (Map.getchildren ()!=null?map.getchildren (). Size (): 0);

Map.addchild (Tamara, z);//Map Creation Class

int mapwidth = (int) (Map.getmapsize (). Width * map.gettilesize (). width);

Tamara.setposition (MAPWIDTH/2, 0);//Set point

Tamara.setanchorpoint (0.5f, 0);//Set Focus

Ccmoveby move = Ccmoveby.action (CGPOINT.CCP (300,250));

Ccmoveby back = Move.reverse ();

Ccsequence seq = ccsequence.actions (move, back);//Move and return

Tamara.runaction (ccrepeatforever.action (seq));//execution

Schedule ("Repositionsprite");

}

public void Repositionsprite (float dt) {

Cgpoint p = tamara.getposition ();//Get Points

Ccnode map = Getchildbytag (ktagtilemap);//Get Maps

int newz = (int) (4-(P.Y/48));//Calculation

Newz = (Newz > 0 newz:0)///greater than 0 returns the new Order


Map.reorderchild (Tamara, Newz);//Adjustment order

}

}

}


Cocos2d-android-1 Source Detailed: 23.tilemaptest1

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.