本文整理汇总了Java中com.badlogic.gdx.utils.Array类的典型用法代码示例。如果您正苦于以下问题:Java Array类的具体用法?Java Array怎么用?Java Array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Array类属于com.badlogic.gdx.utils包,在下文中一共展示了Array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeListenerInVector
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
private boolean removeListenerInVector(Array<EventListener> listeners, EventListener listener) {
if(listeners == null) {return false;}
for(int i = listeners.size - 1; i >= 0; --i) {
EventListener l = listeners.get(i);
if(l == listener) {
l.setRegistered(false);
if(l.getAssociatedNode() != null) {
dissociateNodeAndEventListener(l.getAssociatedNode(), l);
l.setAssociatedNode(null);
}
if(_inDispatch <= 0) {
listeners.removeIndex(i);
} else {
_toRemovedListeners.add(l);
}
return true;
}
}
return false;
}
示例2: initializeGameService
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
/**
* Initialze the 3D game service by instance of GameAsset and GameSetting, CameraManager, ShaderManager and LightManager
* @param asset
* @param baseGameSetting
*/
public void initializeGameService(IGameAsset asset,BaseGameSetting baseGameSetting, CameraManager camera, ShaderManager shader, LightManager light)
{
batch = new SpriteBatch();
scenes = new Array<IScene>();
super.initializeGameService(asset, baseGameSetting);
if(camera == null){
camera = new CameraManager();
}
if(shader == null){
shader = new ShaderManager();
}
if(light == null){
light = new LightManager(new Vector3(0.1f, 0.1f, 0.1f));
}
gameService = new Game3DService(batch, asset, baseGameSetting, sceneManager, camera, shader, light);
}
示例3: testCloudJson
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
@Test
public void testCloudJson() {
Array<Orbiter> orbiters = new Array<>();
Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
orbiterBlueprint.angularVelocity = 70;
int cloudObjectsCount = 10;
for(int i = 0; i < cloudObjectsCount; i++) {
orbiters.add(new Orbiter(new Sprite(), orbiterBlueprint));
}
Cloud saveCloud = new Cloud(orbiters);
String cloudJson = json.toJson(saveCloud);
assertNotEquals("", cloudJson);
Cloud loadCloud = json.fromJson(Cloud.class, cloudJson);
assertNotEquals(null, loadCloud);
assertEquals(cloudObjectsCount, loadCloud.getCloudObjects().size);
assertEquals(70, loadCloud.getAngularVelocity());
}
示例4: createPowerupPickupAnimation
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
private Array<TextureRegion> createPowerupPickupAnimation(){
Array<TextureRegion> animationSequence = new Array<>();
for (int i = 0; i < 8; i++) {
Texture texture;
if (i < 2){
texture = assetService.getTexture(PLAYER_RED);
} else if (i < 4){
texture = assetService.getTexture(PLAYER_GREEN);
} else if (i < 6){
texture = assetService.getTexture(PLAYER_BLUE);
} else {
texture = assetService.getTexture(PLAYER_YELLOW);
}
animationSequence.add(new TextureRegion(texture));
}
return animationSequence;
}
示例5: updateWorldTransform
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
/**
* Updates the world transform for each bone and applies all constraints.
* <p>
* See <a href="http://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
* Runtimes Guide.
*/
public void updateWorldTransform() {
// This partial update avoids computing the world transform for constrained bones when 1) the bone is not updated
// before the constraint, 2) the constraint only needs to access the applied local transform, and 3) the constraint calls
// updateWorldTransform.
Array<Bone> updateCacheReset = this.updateCacheReset;
for (int i = 0, n = updateCacheReset.size; i < n; i++) {
Bone bone = updateCacheReset.get(i);
bone.ax = bone.x;
bone.ay = bone.y;
bone.arotation = bone.rotation;
bone.ascaleX = bone.scaleX;
bone.ascaleY = bone.scaleY;
bone.ashearX = bone.shearX;
bone.ashearY = bone.shearY;
bone.appliedValid = true;
}
Array<Updatable> updateCache = this.updateCache;
for (int i = 0, n = updateCache.size; i < n; i++)
updateCache.get(i).update();
}
示例6: sortIkConstraint
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
private void sortIkConstraint(IkConstraint constraint) {
Bone target = constraint.target;
sortBone(target);
Array<Bone> constrained = constraint.bones;
Bone parent = constrained.first();
sortBone(parent);
if (constrained.size > 1) {
Bone child = constrained.peek();
if (!updateCache.contains(child, true)) updateCacheReset.add(child);
}
updateCache.add(constraint);
sortReset(parent.children);
constrained.peek().sorted = true;
}
示例7: sortPathConstraint
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
private void sortPathConstraint(PathConstraint constraint) {
Slot slot = constraint.target;
int slotIndex = slot.getData().index;
Bone slotBone = slot.bone;
if (skin != null) sortPathConstraintAttachment(skin, slotIndex, slotBone);
if (data.defaultSkin != null && data.defaultSkin != skin)
sortPathConstraintAttachment(data.defaultSkin, slotIndex, slotBone);
for (int ii = 0, nn = data.skins.size; ii < nn; ii++)
sortPathConstraintAttachment(data.skins.get(ii), slotIndex, slotBone);
Attachment attachment = slot.attachment;
if (attachment instanceof PathAttachment) sortPathConstraintAttachment(attachment, slotBone);
Array<Bone> constrained = constraint.bones;
int boneCount = constrained.size;
for (int ii = 0; ii < boneCount; ii++)
sortBone(constrained.get(ii));
updateCache.add(constraint);
for (int ii = 0; ii < boneCount; ii++)
sortReset(constrained.get(ii).children);
for (int ii = 0; ii < boneCount; ii++)
constrained.get(ii).sorted = true;
}
示例8: EditorManager
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
public EditorManager(){
FileChooser.setDefaultPrefsName("white-ui-editor");
FileChooser.setSaveLastDirectory(true);
events = new Array<>();
assetManager = new AssetManager();
assetManager.load("badlogic.jpg", Texture.class);
assetManager.load("icon/select.9.png",Texture.class);
assetManager.load("icon/align_left.png",Texture.class);
assetManager.load("icon/align_right.png",Texture.class);
assetManager.load("icon/align_center.png",Texture.class);
assetManager.load("icon/align_h_center.png",Texture.class);
assetManager.load("icon/align_bottom.png",Texture.class);
assetManager.load("icon/align_top.png",Texture.class);
assetManager.load("icon/label.png",Texture.class);
assetManager.load("icon/image.png",Texture.class);
assetManager.load("icon/group.png",Texture.class);
assetManager.load("icon/button.png",Texture.class);
assetManager.load("icon/checkbox.png",Texture.class);
assetManager.load("icon/textfield.png",Texture.class);
assetManager.finishLoading();
}
示例9: BossEnemy
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
/**
* Sets up the enemy in the game
* @param screen the play screen
* @param spawnPositionX the spawn position as tile index on the x axis
* @param spawnPositionY the spawn position as tile index on the y axis
*/
public BossEnemy(PlayScreen screen, float spawnPositionX, float spawnPositionY) {
super(screen, spawnPositionX, spawnPositionY);
playScreen = screen;
// Set gameplay variables of super class for this specific type of enemy
damageMinMax = new int[] { 10, 20 };
health = 50;
horizontalMoveImpulseVelocity = 0.1f;
horizontalMaxMovementVelocity = 0.5f;
// Animation set up
flyFrames = new Array<>();
for(int i = 0; i < 12; i++) {
flyFrames.add(new TextureRegion(screen.getEnemyBossTextureAtlas().findRegion("bird"), 0, i * ENEMY_PIXEL_HEIGHT, ENEMY_PIXEL_WIDTH, ENEMY_PIXEL_HEIGHT)
);
}
flyAnimation = new Animation<TextureRegion>(0.2f, flyFrames);
currentAnimation = "bird_fly";
stateTime = 0;
setBounds(getX(), getY(), ENEMY_PIXEL_WIDTH / MainGameClass.PPM, ENEMY_PIXEL_HEIGHT / MainGameClass.PPM + getHeight() / 2);
}
示例10: register
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
public boolean register(String event, Object user, OnEventCallback callback) {
Array<StructEvent> events = eventMap.get(event);
if(events == null) {
events = new Array<StructEvent>();
eventMap.put(event, events);
}
StructEvent newEvent;
if(user == null) {
newEvent = new StructEvent(user, callback);
} else {
for(StructEvent e : events) {
if(user == e.user) {
BaseLog.warning(TAG, "event already in map : " + event + " " + user);
return false;
}
}
newEvent = new StructEvent(user, callback);
}
events.add(newEvent);
return true;
}
示例11: trigger
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
/**触发事件*/
public boolean trigger(String event, Object...args) {
Array<StructEvent> events = eventMap.get(event);
if(events == null) {
// SLog.warning(TAG, "event not found : " + event);
return false;
}
final int len = events.size;
//使用副本来执行call —— 支持在执行过程中修改源数据
StructEvent[] structEvents = new StructEvent[len];
for(int i = 0; i < len; ++i) {
structEvents[i] = events.get(i);
}
for(int i = 0; i < len; ++i) {
structEvents[i].call(event, args);
}
structEvents = null;
return true;
}
示例12: initEntities
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
private void initEntities(TextureAtlas textureAtlas) {
final float mobWidth = Polymorph.WORLD_WIDTH/4;
player = new Player(new Vector2(Polymorph.WORLD_WIDTH/2 - mobWidth/2, Polymorph.WORLD_HEIGHT/3-mobWidth),
new Dimension(mobWidth, mobWidth));
slots = new Array<Slot>();
slotPool = new Pool<Slot>() {
@Override
protected Slot newObject() {
return new Slot(new Vector2(SLOT_SPAWN_POINT),
new Vector2(slotVelocity),
new Dimension(mobWidth, mobWidth));
}
};
Dimension mapSize = new Dimension(Polymorph.WORLD_WIDTH, (int)(Polymorph.WORLD_HEIGHT*1.1f));
TextureRegion mapTexture = textureAtlas.findRegion("background");
Map mapFront = new Map(new Vector2(0, 0), mapVelocity, mapSize, mapTexture);
Map mapBack = new Map(new Vector2(0, -mapSize.height + 5), mapVelocity, mapSize, mapTexture);
maps = new Map[]{mapFront, mapBack};
}
示例13: addSpriteFrameWithTextureAtlas
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
/**
* 读取gdx textureAtlas文件
* @param filePath atlas 文件路径 也可以自定义
* @param atlas
*/
public void addSpriteFrameWithTextureAtlas(String filePath, TextureAtlas atlas) {
if(_atlases.containsKey(filePath)) {
CCLog.debug(this.getClass(), "file loaded : " + filePath);
return;
}
_atlases.put(filePath, atlas);
Array<AtlasRegion> rs = atlas.getRegions();
for(AtlasRegion r : rs) {
TextureRegion ret = _spriteFrames.put(r.name, r);
if(ret != null) {
CCLog.debug(this.getClass(), "region name exists : " + r.name);
}
}
}
示例14: fetchGameStates
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
@Override
public boolean fetchGameStates(final IFetchGameStatesListResponseListener callback) {
if (!driveApiEnabled)
throw new UnsupportedOperationException("To use game states, enable Drive API when initializing");
if (connected) {
background(new SafeRunnable() {
@Override
public void run() throws IOException {
Array<String> result = null;
try {
result = fetchGameStatesSync();
} finally {
callback.onFetchGameStatesListResponse(result);
}
}
});
}
return connected;
}
示例15: fetchLeaderboardEntries
import com.badlogic.gdx.utils.Array; //导入依赖的package包/类
@Override
public boolean fetchLeaderboardEntries(final String leaderBoardId, final int limit, final boolean
relatedToPlayer, final IFetchLeaderBoardEntriesResponseListener callback) {
if (connected) {
background(new SafeRunnable() {
@Override
public void run() throws IOException {
Array<ILeaderBoardEntry> result = null;
try {
result = fetchLeaderboardSync(leaderBoardId, limit, relatedToPlayer, false);
} finally {
callback.onLeaderBoardResponse(result);
}
}
});
}
return connected;
}