當前位置: 首頁>>代碼示例>>Java>>正文


Java Array.clear方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.utils.Array.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java Array.clear方法的具體用法?Java Array.clear怎麽用?Java Array.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.utils.Array的用法示例。


在下文中一共展示了Array.clear方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unregisterAll

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/**刪除指定名稱下所有的事件 */
public boolean unregisterAll(String event) {
	Array<StructEvent> events = eventMap.get(event);
	if(events == null) {
		BaseLog.warning(TAG, "event not found : " + event);
		return false;
	}
	events.clear();
	eventMap.remove(event);
	return true;
}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:12,代碼來源:EventManager.java

示例2: Hero

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public Hero(World world, PlayScreen screen) {
    super(screen.getAtlas().findRegion("dudeRun4"));
    this.world = world;
    currentState = State.STANDING;
    previousState = State.STANDING;
    stateTimer = 0;
    runningRight = true;
    isLanded = true;
    this.playScreen = screen;

    Array<TextureRegion> frames = new Array<TextureRegion>();
    //running animation
    for (int i = 1; i < 5; i++) {
        frames.add(new TextureRegion(getTexture(), i * 53, 2, 40, 60));
    }
    heroRun = new Animation(0.1f, frames);
    frames.clear();

    //climbing animation
    for (int i = 6; i < 9; i++) {
        frames.add(new TextureRegion(getTexture(), i * 53, 2, 40, 60));
    }
    heroClimb = new Animation(0.1f, frames);


    defineHero();

    //determines size and starting position of standing on spritesheet
    heroStand = new TextureRegion(getTexture(), 2, 2, 40, 60);
    setBounds(0, 0, 40 / NoObjectionGame.PPM, 60 / NoObjectionGame.PPM);
    setRegion(heroStand);
}
 
開發者ID:MissionBit,項目名稱:summer17-android,代碼行數:33,代碼來源:Hero.java

示例3: act

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
@Override
public void act(float delta) {
	super.act(delta);
	for (int i = 0; i < cell_arrays.size; i++) {
		Array<MapTile> tile_array = cell_arrays.get(i);
		for (int j = 0; j < tile_array.size; j++) {
			tile_pool.free(tile_array.get(j));
		}
		tile_array.clear();
	}
	getTCAPool().freeAll(cell_arrays);
	cell_arrays.clear();
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:14,代碼來源:TilemapLayerObject.java

示例4: unloadFonts

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public void unloadFonts() {
	Array<BitmapFont> fvalues = fonts.values().toArray();
	AssetManager am = game.getAssetManager();
	unload_helper.clear();
	for (int i = 0; i < fvalues.size; i++) {
		unload_helper.add(fvalues.get(i).getData().fontFile.path());
	}

	fvalues.clear();
	for (int i = 0; i < unload_helper.size; i++) {
		am.unload(unload_helper.get(i));
	}
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:14,代碼來源:GameState.java

示例5: update

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/** Clears any previous polygons, finds all visible bounding box attachments, and computes the world vertices for each bounding
 * box's polygon.
 * @param updateAabb If true, the axis aligned bounding box containing all the polygons is computed. If false, the
 *           SkeletonBounds AABB methods will always return true. */
public void update (Skeleton skeleton, boolean updateAabb) {
	if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
	Array<BoundingBoxAttachment> boundingBoxes = this.boundingBoxes;
	Array<FloatArray> polygons = this.polygons;
	Array<Slot> slots = skeleton.slots;
	int slotCount = slots.size;

	boundingBoxes.clear();
	polygonPool.freeAll(polygons);
	polygons.clear();

	for (int i = 0; i < slotCount; i++) {
		Slot slot = slots.get(i);
		Attachment attachment = slot.attachment;
		if (attachment instanceof BoundingBoxAttachment) {
			BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
			boundingBoxes.add(boundingBox);

			FloatArray polygon = polygonPool.obtain();
			polygons.add(polygon);
			boundingBox.computeWorldVertices(slot, polygon.setSize(boundingBox.getWorldVerticesLength()));
		}
	}

	if (updateAabb)
		aabbCompute();
	else {
		minX = Integer.MIN_VALUE;
		minY = Integer.MIN_VALUE;
		maxX = Integer.MAX_VALUE;
		maxY = Integer.MAX_VALUE;
	}
}
 
開發者ID:laurencegw,項目名稱:jenjin,代碼行數:38,代碼來源:SkeletonBounds.java

示例6: dispatchTouchEvent

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/** Touch event needs to be processed different with other events since it needs support ALL_AT_ONCE and ONE_BY_NONE mode. */
public void dispatchTouchEvent(EventTouch event) {
	sortEventListeners(EventListenerTouchOneByOne.LISTENER_ID);
	sortEventListeners(EventListenerTouchAllAtOnce.LISTENER_ID);
	
	EventListenerVector oneByOneListeners = getListeners(EventListenerTouchOneByOne.LISTENER_ID);
	EventListenerVector allAtOnceListeners = getListeners(EventListenerTouchAllAtOnce.LISTENER_ID);
    
    // If there aren't any touch listeners, return directly.
    if (null == oneByOneListeners && null == allAtOnceListeners) {return;}
    
    boolean isNeedsMutableSet = (oneByOneListeners != null && allAtOnceListeners != null);
    
    final Array<Touch> originalTouches = event.getTouches();
    //TODO stack
    _poolTouchArray.clear();
    Array<Touch> mutableTouches =  _poolTouchArray;
    mutableTouches.clear();
    mutableTouches.addAll(originalTouches);

    //
    // process the target handlers 1st
    //
    if (oneByOneListeners != null) {
    	int mutableTouchesIter = 0;
    	int touchesIter = 0;
        
        for (; touchesIter < originalTouches.size; ++touchesIter)
        {
            boolean isSwallowed = false;
            Touch currTouch = originalTouches.get(touchesIter);
            
            //
            onTouchEvent.init(event, currTouch, isNeedsMutableSet, isSwallowed, 
            		mutableTouches, mutableTouchesIter);
            
            dispatchTouchEventToListeners(oneByOneListeners, onTouchEvent);
            
            isSwallowed = onTouchEvent.isSwallowed;
            mutableTouchesIter = onTouchEvent.mutableTouchesIter;
            
            if (event.isStopped()) 	{return;}
            if (!isSwallowed) 		{++mutableTouchesIter;}
        }
    }
    
    //
    // process standard handlers 2nd
    //
    if (allAtOnceListeners != null && mutableTouches.size > 0) { 
    	
    	onTouchesEvent.init(event, mutableTouches);
        
        dispatchTouchEventToListeners(allAtOnceListeners, onTouchesEvent);
        if (event.isStopped()) {return;}
    }
    updateListeners(event);
}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:59,代碼來源:EventDispatcher.java

示例7: main

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public static void main(String[] args) {
		QuadTree qt = new QuadTreeV2();
		for(int i = 0; i <50; ++i) {
			for(int j = 0; j < 50; ++j) {
				qt.addObject(createQuadTreeObject(0 + 12 * i, 0 + 12 * j));
			}
		}
//		qt.addObject(createQuadTreeObject(-50,0));
//		qt.addObject(createQuadTreeObject(-40,0));
//		qt.addObject(createQuadTreeObject(-30,0));
//		qt.addObject(createQuadTreeObject(-20,0));
//		qt.addObject(createQuadTreeObject(-10,0));
//		qt.addObject(createQuadTreeObject(0,0));
//		qt.addObject(createQuadTreeObject(10,0));
//		qt.addObject(createQuadTreeObject(20,0));
//		qt.addObject(createQuadTreeObject(30,0));
//		qt.addObject(createQuadTreeObject(40,0));
//		
//		qt.addObject(createQuadTreeObject(10,-20));
//		qt.addObject(createQuadTreeObject(20,20));
//		qt.addObject(createQuadTreeObject(30,20));
//		qt.addObject(createQuadTreeObject(40,20));
		
		qt.build();
		
//		qt.visit();
		
//		if(true) return;
		Array<IQuadTreeObject> ret = new Array<IQuadTreeObject>(256);
		Rectangle rect = new Rectangle(200, 100, 100, 80);
		//ʮ���IJ�����ѯ
		long time = 0;
		int n = 1000;
		
		//ʮ�����Բ�ѯ
//		time = System.nanoTime();
//		for(int i = 0; i < n; i++) {
//			qt.slowQuery(rect, ret);
//			if(i < n-1) { 
//				ret.clear();
//			}
//		}
//		System.out.println("���Բ�ѯ���� ��� = " + ret.size + " ʱ�� = " + (System.nanoTime() - time));
//		
		time = System.currentTimeMillis();
		
		for(int i = 0; i < n; i++) {
			qt.query(rect, ret);
			if(i < n-1) { 
				ret.clear();
			}
		}

		System.out.println("�IJ���2��ѯ���� ��� = " + ret.size + 
				" ʱ�� = " + (System.currentTimeMillis() - time));
//		System.out.println("�IJ���2��ѯ���� ��� = " + ret.size + 
//				" ʱ�� = " + (System.nanoTime() - time)/1000);
		ret.clear();
	}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:60,代碼來源:QuadTreeV2.java

示例8: main

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public static void main(String[] args) {
		QuadTree qt = new QuadTree();
		for(int i = 0; i <50; ++i) {
			for(int j = 0; j < 50; ++j) {
				qt.addObject(createQuadTreeObject(0 + 12 * i, 0 + 12 * j));
			}
		}
//		qt.addObject(createQuadTreeObject(-50,0));
//		qt.addObject(createQuadTreeObject(-40,0));
//		qt.addObject(createQuadTreeObject(-30,0));
//		qt.addObject(createQuadTreeObject(-20,0));
//		qt.addObject(createQuadTreeObject(-10,0));
//		qt.addObject(createQuadTreeObject(0,0));
//		qt.addObject(createQuadTreeObject(10,0));
//		qt.addObject(createQuadTreeObject(20,0));
//		qt.addObject(createQuadTreeObject(30,0));
//		qt.addObject(createQuadTreeObject(40,0));
//		
//		qt.addObject(createQuadTreeObject(10,-20));
//		qt.addObject(createQuadTreeObject(20,20));
//		qt.addObject(createQuadTreeObject(30,20));
//		qt.addObject(createQuadTreeObject(40,20));
		
		qt.build();
		
//		qt.visit();
		
//		if(true) return;
		
		Array<IQuadTreeObject> ret = new Array<IQuadTreeObject>(256);
		Rectangle rect = new Rectangle(200, 100, 100, 80);
		//ʮ���IJ�����ѯ
		long time = 0;
		int n = 1000;
		
		//ʮ�����Բ�ѯ
//		time = System.nanoTime();
//		for(int i = 0; i < n; i++) {
//			qt.slowQuery(rect, ret);
//			if(i < n-1) { 
//				ret.clear();
//			}
//		}
//		System.out.println("���Բ�ѯ���� ��� = " + ret.size + " ʱ�� = " + (System.nanoTime() - time));
		
		time = System.currentTimeMillis();
		
		for(int i = 0; i < n; i++) {
			qt.query(rect, ret);
			if(i < n-1) { 
				ret.clear();
			}
		}
		System.out.println("�IJ�����ѯ���� ��� = " + ret.size + 
				" ʱ�� = " + (System.currentTimeMillis() - time));
		ret.clear();
	}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:58,代碼來源:QuadTree.java

示例9: getSprites

import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
Array<AtlasRegion> getSprites(Tile tile) {
	Array<AtlasRegion> sprites = new Array<>();
	
	/*
		Steps:
			- get a list of the different tile types around the given tile, ordered according to the z index.
			- remove all types from the list that are at or below the given tile's z index.
			- iterate through each type, looking for the following:
				- find all overlap situations that the other type matches, and add that type's overlap sprite(s) to the list of sprites to render
				
	 */
	
	TileType[] aroundTiles = new TileType[9];
	TreeSet<TileType> types = new TreeSet<>(TileType.tileSorter);
	int i = 0;
	for(int x = -1; x <= 1; x++) {
		for (int y = -1; y <= 1; y++) {
			Tile oTile = tile.getLevel().getTile(tile.x + x, tile.y + y);
			if(oTile != null) {
				aroundTiles[i] = useSurface ? oTile.getSurfaceType() : oTile.getGroundType();
				
				if(aroundTiles[i] != null && aroundTiles[i].getProp(OverlapProperty.class).overlaps)
					types.add(aroundTiles[i]);
			}
			i++;
		}
	}
	
	types.removeIf(tileType -> TileType.tileSorter.compare(tileType, this.tileType) <= 0);
	
	Array<Integer> indexes = new Array<>();
	for(TileType type: types) {
		indexes.clear();
		
		int[] bits = new int[4];
		if(aroundTiles[1] == type) bits[0] = 1;
		if(aroundTiles[5] == type) bits[1] = 1;
		if(aroundTiles[7] == type) bits[2] = 1;
		if(aroundTiles[3] == type) bits[3] = 1;
		int total = 4, value = 1;
		for(int num: bits) {
			total += num * value;
			value *= 2;
		}
		indexes.add(total);
		if(aroundTiles[2] == type && bits[0] == 0 && bits[1] == 0) indexes.add(0);
		if(aroundTiles[8] == type && bits[1] == 0 && bits[2] == 0) indexes.add(1);
		if(aroundTiles[6] == type && bits[2] == 0 && bits[3] == 0) indexes.add(2);
		if(aroundTiles[0] == type && bits[3] == 0 && bits[0] == 0) indexes.add(3);
		for(Integer idx: indexes)
			sprites.add(type.getProp(AnimationProperty.class).getSprite(idx, true, tile));
	}
	return sprites;
}
 
開發者ID:chrisj42,項目名稱:miniventure,代碼行數:55,代碼來源:OverlapProperty.java


注:本文中的com.badlogic.gdx.utils.Array.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。