真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Cocos2D-Android-1之源碼詳解:23.TileMapTest1

package org.cocos2d.tests;

創(chuàng)新互聯(lián)提供高防主機(jī)、云服務(wù)器、香港服務(wù)器、IDC機(jī)房托管

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();//得到類的名字,若很多則返回很多

    private CCGLSurfaceView mGLSurfaceView;

    @Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            mGLSurfaceView = new CCGLSurfaceView(this);//實(shí)例化view

            setContentView(mGLSurfaceView);//加載view

            CCDirector.sharedDirector().attachInView(mGLSurfaceView);//附加開放圖形語言視圖

            CCDirector.sharedDirector().setLandscape(false);//設(shè)置觀景模式

            CCDirector.sharedDirector().setDisplayFPS(true);

            CCDirector.sharedDirector().setAnimationInterval(1.0f / 30);

            CCScene scene = CCScene.node();//必要的構(gòu)造

            scene.addChild(new TMXIsoZorder());//屬于next的子類

            CCDirector.sharedDirector().runWithScene(scene);

        }

    public static final int kTagTileMap = 1;

    static class TMXIsoZorder extends CCLayer {//1

        CCSprite tamara;//精靈

        public TMXIsoZorder() {

            super();

            CCTMXTiledMap map = CCTMXTiledMap.tiledMap("iso-test-zorder.tmx");//創(chuàng)建地圖

            addChild(map, 0, kTagTileMap);//添加子類

            map.setPosition(-1000,-50);//設(shè)置點(diǎn)

            tamara = CCSprite.sprite("grossinis_sister1.png");//創(chuàng)建精靈

            int z = (map.getChildren()!=null?map.getChildren().size():0);

            map.addChild(tamara, z);//地圖創(chuàng)建類

            int mapWidth = (int) (map.getMapSize().width * map.getTileSize().width);

            tamara.setPosition( mapWidth/2, 0);//設(shè)置點(diǎn)

            tamara.setAnchorPoint(0.5f, 0);//設(shè)置焦點(diǎn)

            CCMoveBy move = CCMoveBy.action(10, CGPoint.ccp(300,250));

            CCMoveBy back = move.reverse();

            CCSequence seq = CCSequence.actions(move, back);//移動(dòng)和返回

            tamara.runAction(CCRepeatForever.action(seq));//執(zhí)行

            schedule("repositionSprite");

        }

        public void repositionSprite(float dt) {

            CGPoint p = tamara.getPosition();//得到點(diǎn)

            CCNode map = getChildByTag(kTagTileMap);//得到地圖

            int newZ = (int) (4 - (p.y / 48));//計(jì)算

            newZ = (newZ > 0 ? newZ : 0);//大于0就返回新順序

            map.reorderChild(tamara, newZ);//調(diào)整順序

        }

    }

}


文章題目:Cocos2D-Android-1之源碼詳解:23.TileMapTest1
文章分享:http://www.weahome.cn/article/goseps.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部