当前位置: 首页>>代码示例>>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;未经允许,请勿转载。