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; }
/** * 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); }
@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()); }
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; }
/** * 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(); }
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; }
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; }
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(); }
/** * 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); }
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; }
/**触发事件*/ 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; }
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}; }
/** * 读取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); } } }
@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; }
@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; }
protected void createCachedAnimations(Map<String, Integer> map) { int i = 0; for (Map.Entry<String, Integer> entry : map.entrySet()) { String animationName = entry.getKey(); int frameCounter = entry.getValue(); // calculate duration per frame float durationPerFrame = this.sumDuration / frameCounter; // get regions Array<TextureAtlas.AtlasRegion> regions = this.atlas.findRegions(animationName); // create animation Animation<TextureRegion> anim = new Animation<>(durationPerFrame, regions, Animation.PlayMode.LOOP); // add animation to map this.animationMap.put(animationName, anim); i++; } }
/** * {@inheritDoc} */ @Override public <T, R extends T> void onDataChange(Class<T> dataType, DataChangeListener<R> listener) { if (listener != null) { DataChangeValueListener<T, R> dataChangeListener = new DataChangeValueListener<>(dataType, listener); if (!valueEventListeners.containsKey(databasePath)) valueEventListeners.put(databasePath, new Array<ValueEventListener>()); valueEventListeners.get(databasePath).add(dataChangeListener); databaseReference().addValueEventListener(dataChangeListener); } else { Array<ValueEventListener> listeners = valueEventListeners.get(databasePath); for (ValueEventListener v : listeners) { databaseReference().removeEventListener(v); } } terminateOperation(); }
public boolean executeRunnables() { Array var1 = this.runnables; synchronized (this.runnables) { int i = this.runnables.size - 1; while (true) { if (i < 0) { this.runnables.clear(); break; } this.executedRunnables.addAll(new Runnable[]{(Runnable) this.runnables.get(i)}); --i; } } if (this.executedRunnables.size == 0) { return false; } else { do { ((Runnable) this.executedRunnables.pop()).run(); } while (this.executedRunnables.size > 0); return true; } }
/** Sorts the listeners of specified type by scene graph priority */ public void sortEventListenersOfSceneGraphPriority(final String listenerID, INode rootNode) { EventListenerVector listeners = getListeners(listenerID); if (listeners == null) {return;} Array<EventListener> sceneGraphListeners = listeners.getSceneGraphPriorityListeners(); if (sceneGraphListeners == null) {return;} // Reset priority index _nodePriorityIndex = 0; _nodePriorityMap.clear(); visitTarget(rootNode, true); // After sort: priority < 0, > 0 sceneGraphListeners.sort(new Comparator<EventListener>() { @Override public int compare(EventListener l1, EventListener l2) { int p1 = _nodePriorityMap.get(l1._node); int p2 = _nodePriorityMap.get(l2._node); return p1 - p2; } }); // std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) { // return _nodePriorityMap[l1->getAssociatedNode()] > _nodePriorityMap[l2->getAssociatedNode()]; // }); // #if DUMP_LISTENER_ITEM_PRIORITY_INFO // log("-----------------------------------"); // for (auto& l : *sceneGraphListeners) // { // log("listener priority: node ([%s]%p), priority (%d)", typeid(*l->_node).name(), l->_node, _nodePriorityMap[l->_node]); // } // #endif }
public SkeletonActorPool (SkeletonRenderer renderer, SkeletonData skeletonData, AnimationStateData stateData, int initialCapacity, int max) { super(initialCapacity, max); this.renderer = renderer; this.skeletonData = skeletonData; this.stateData = stateData; obtained = new Array(false, initialCapacity); skeletonPool = new Pool<Skeleton>(initialCapacity, max) { protected Skeleton newObject () { return new Skeleton(SkeletonActorPool.this.skeletonData); } protected void reset (Skeleton skeleton) { skeleton.setColor(Color.WHITE); skeleton.setFlip(false, false); skeleton.setSkin((Skin)null); skeleton.setSkin(SkeletonActorPool.this.skeletonData.getDefaultSkin()); skeleton.setToSetupPose(); } }; statePool = new Pool<AnimationState>(initialCapacity, max) { protected AnimationState newObject () { return new AnimationState(SkeletonActorPool.this.stateData); } protected void reset (AnimationState state) { state.clearTracks(); state.clearListeners(); } }; }
private void cleanToRemovedListeners() { for(EventListener l : _toRemovedListeners) { EventListenerVector listeners = _listenerMap.get(l.getListenerID()); if(listeners == null) { continue; } boolean find = false; Array<EventListener> fixedPriorityListeners = listeners.getFixedPriorityListeners(); Array<EventListener> sceneGraphPriorityListeners = listeners.getSceneGraphPriorityListeners(); if (sceneGraphPriorityListeners != null) { if(sceneGraphPriorityListeners.removeValue(l, true)) {find = true;} } if (fixedPriorityListeners != null) { if(fixedPriorityListeners.removeValue(l, true)) {find = true;} } if (find) { if (sceneGraphPriorityListeners != null && sceneGraphPriorityListeners.size <= 0) { listeners.clearSceneGraphListeners(); } if (fixedPriorityListeners != null && fixedPriorityListeners.size <= 0) { listeners.clearFixedListeners(); } } } _toRemovedListeners.clear(); }
@Test public void testRingJson() { Array<Orbiter> array = new Array<>(); int objectCount = 10; for(int i = 0; i < objectCount; i++) { array.add(new Orbiter(null, new Orbiter.OrbiterBlueprint())); } ColorGroup colorGroup = new ColorGroup() .add(Color.rgba8888(1, 0, 0, 1)) .add(Color.rgba8888(0, 0, 1, 1)); Ring saveRing = new Ring(array, colorGroup, 10, 50); saveRing.setAngularVelocity(100); saveRing.setXTilt(25); saveRing.setZTilt(50); String ringJson = json.toJson(saveRing); assertNotEquals("", ringJson); Ring loadRing = json.fromJson(Ring.class, ringJson); assertNotEquals(null, loadRing); assertEquals(10, loadRing.getMinimumRadius()); assertEquals(50, loadRing.getMaximumRadius()); assertEquals(100, loadRing.getAngularVelocity()); assertEquals(25, loadRing.getXTilt()); assertEquals(50, loadRing.getZTilt()); }
public void convertSaves(){ Array<SaveSlot> invalid = new Array<>(); for(SaveSlot slot : saves){ if(!SaveIO.checkConvert(slot.index)){ invalid.add(slot); } } saves.removeAll(invalid, true); }
public Array<Tile> getAreaTiles(int xt, int yt, int radius, boolean includeCenter) { Array<Tile> tiles = new Array<>(); for(int x = Math.max(0, xt-radius); x <= Math.min(width-1, xt+radius); x++) { for(int y = Math.max(0, yt-radius); y <= Math.min(height-1, yt+radius); y++) { tiles.add(this.tiles[x][y]); } } if(!includeCenter) tiles.removeValue(this.tiles[xt][yt], true); return tiles; }
/** 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; } }
public void init() { // Load TMX Map spawnPoints = new Array<Vector2>(); tiledMap = new TmxMapLoader().load(mapName); spawnLayer = tiledMap.getLayers().get("BasicAlienSpawn"); loadSpawnLocations(spawnLayer); }
/** Convenience method for generating a font, and then writing the fnt and png files. * Writing a generated font to files allows the possibility of only generating the fonts when they are missing, otherwise * loading from a previously generated file. * @param fontFile * @param fontSize */ private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight) { FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile); PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = fontSize; parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS; parameter.packer = packer; FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);//(fontSize, FreeTypeFontGenerator.DEFAULT_CHARS, false, packer); Array<PixmapPacker.Page> pages = packer.getPages(); Array<TextureRegion> texRegions = new Array<TextureRegion>(pageSize); for (int i=0; i<pages.size; i++) { PixmapPacker.Page p = pages.get(i); Texture tex = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) { @Override public void dispose () { super.dispose(); getTextureData().consumePixmap().dispose(); } }; tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest); texRegions.add(new TextureRegion(tex)); } BitmapFont font = new BitmapFont(fontData,texRegions,false); //fontData, texRegions, false); saveFontToFile(font, fontSize, fontName, packer); generator.dispose(); packer.dispose(); return font; }
public Ground(Array<Body> bodies) { ground = bodies.first();//first item sky = bodies.peek();//last item textureRegionGround = AssetsManager.getTextureRegion(Constants.GROUND_IMAGE_NAME); textureRegionSky = AssetsManager.getTextureRegion(Constants.SKY_IMAGE_NAME); groundPositions1 = new Vector2(0, 0); groundPositions2 = new Vector2(Constants.WIDTH, 0); }
/** * 设置搜索路径 搜索优先级:从前到后 * @param searchPaths */ public void setSearchPaths(Array<FullFilePath> searchPaths) { _searchPathArray.clear(); for(FullFilePath f : searchPaths) { this._searchPathArray.add(f); } }
@Override public void read(Json json, JsonValue jsonData) { minRadius = json.readValue("minimumRadius", Float.class, jsonData); maxRadius = json.readValue("maximumRadius", Float.class, jsonData); angularVelocity = json.readValue("angularVelocity", Float.class, jsonData); zTilt = json.readValue("zTilt", Float.class, jsonData); xTilt = json.readValue("xTilt", Float.class, jsonData); colors = json.readValue("colorGroup", ColorGroup.class, jsonData); this.baseObjectCount = json.readValue("objectCount", Integer.class, jsonData); objects = new Array<>(baseObjectCount); }
public PhysicsGenerator addGenerator(PhysicsGenerator generator, boolean checkContains) { if(generatorList == null) { generatorList = new Array<PhysicsGenerator>(2); } checkGeneratorCount(); if(checkContains) { if(findGenerator(generator)) { CCLog.engine("PhysicsObject", "generator already exist! "); return generator; } } generatorList.add(generator); return generator; }
private void createStarsClicked() { if(starEditor == null || starEditor.hasDeleteBeenPressed()) { starEditor = new StarEditor(scene, "Stars"); addObjectEditor(starEditor); } else { starEditor.deleteObjects(); } Array<Star> stars = scene.getObjectGenerator().createStars(); starEditor.setStars(stars); }
public Animation(TextureRegion region, int frameCount, float cycleTime) { frames = new Array<TextureRegion>(); int frameWidth = region.getRegionWidth() / frameCount; for ( int i = 0; i < frameCount; i++){ frames.add(new TextureRegion(region, i * frameWidth, 0, frameWidth, region.getRegionHeight())); } this.frameCount = frameCount; maxFrameTime = cycleTime / frameCount; frame = 0; }
public Quad(QuadTree manager) { this.pool = manager.getPool(); this.manager = manager; quad_objects = new Array<GameObject>(); bounds = new Rectangle(); quads = new Quad[4]; }
@Override public void create() { Array<String> names = getCore().getImagePacks().get(DATA_PATH + "/obstacles"); obstacleTexture = getCore().getAtlas().findRegion(names.random()); obstacleFlipped = new TextureRegion(obstacleTexture); obstacleFlipped.flip(false, true); timer = (obstacleTexture.getRegionWidth() + GameState.OBSTACLE_GAP) / GameState.SCROLL_SPEED; }
@Override public void freeAll(Array<T> array) { if (array == null) throw new IllegalArgumentException("array cannot be null"); for (T t : array) { free(t); } }
@Override public void getStats(Array<String> list){ super.getStats(list); list.add("[liquidinfo]Liquid Capacity: " + (int)liquidCapacity); list.add("[liquidinfo]Power/Liquid: " + Strings.toFixed(powerPerLiquid, 2) + " power/liquid"); list.add("[liquidinfo]Max liquid/second: " + Strings.toFixed(maxLiquidGenerate*60f, 2) + " liquid/s"); list.add("[liquidinfo]Input: " + generateLiquid); }
/** @noinspection UnusedReturnValue*/ public static Array<Tile> sortByDistance(Array<Tile> tiles, final Vector2 position) { tiles.sort((t1, t2) -> { float t1diff = position.dst(t1.getBounds().getCenter(new Vector2())); float t2diff = position.dst(t2.getBounds().getCenter(new Vector2())); return Float.compare(t1diff, t2diff); }); return tiles; }
/** Generate vertex attributes suitable for multi-texturing and vertex color. 32 bit floats are used for each position * component and texture coordinate. The four color components are packed into a single 32 bit float. * @param textureCount The number of textures to support. * @param position3D Whether the position attribute should include a Z component. * @param textureCoordinates3D Whether the texture coordinate attribute(s) should include a third component. * @param attributes The array to add the vertex attributes to. They are added with position and color in the first two * available positions, followed by texture coordinates. */ public static void addBaseAttributes (Array<VertexAttribute> attributes, int textureCount, boolean position3D, boolean textureCoordinates3D) { attributes.add(new VertexAttribute(Usage.Position, position3D ? 3 : 2, ShaderProgram.POSITION_ATTRIBUTE)); attributes.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE)); for (int i = 0; i < textureCount; i++) { attributes.add( new VertexAttribute(Usage.TextureCoordinates, textureCoordinates3D ? 3 : 2, ShaderProgram.TEXCOORD_ATTRIBUTE + i, i)); } }
/** * Finds a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it * multiple times. * * @return May be null. */ public Bone findBone(String boneName) { if (boneName == null) throw new IllegalArgumentException("boneName cannot be null."); Array<Bone> bones = this.bones; for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); if (bone.data.name.equals(boneName)) return bone; } return null; }