public WalkingGameObject(TextureSheetAnimationInfo sheetInfo, long id, CollisionMap<GameObject> linkedCollisionMap) { super(Assets.get("nullTexture.png"), id, linkedCollisionMap); Texture charactersTexture = sheetInfo.texture; TextureRegion[][] charactersTextures = Sprite.split(charactersTexture, charactersTexture.getWidth() / sheetInfo.textureTileWidth, charactersTexture.getHeight() / sheetInfo.textureTileHeight); TextureRegion[][] characterTextures = filter(charactersTextures, sheetInfo.textureTileXOffset, sheetInfo.textureTileYOffset, sheetInfo.textureCountedTileWidth, sheetInfo.textureCountedTileHeight); textureToDraw = characterTextures[0][0]; setSize(textureToDraw.getRegionWidth(), textureToDraw.getRegionHeight()); moveDownAnimation = new CustomAnimation<>(animationFrameDuration, characterTextures[0]); moveLeftAnimation = new CustomAnimation<>(animationFrameDuration, characterTextures[1]); moveRightAnimation = new CustomAnimation<>(animationFrameDuration, characterTextures[2]); moveUpAnimation = new CustomAnimation<>(animationFrameDuration, characterTextures[3]); moveUpAnimation.setPlayMode(PlayMode.LOOP); moveLeftAnimation.setPlayMode(PlayMode.LOOP); moveDownAnimation.setPlayMode(PlayMode.LOOP); moveRightAnimation.setPlayMode(PlayMode.LOOP); }
public AnimatedSprite(String key, float totalDuration, Integer numLoops, State state) { super(); Array<AtlasRegion> frames = AssetManager.getInstance().getTextureRegions(key); float frameDuration = ConversionUtils.ms2s(totalDuration / frames.size); rawAnimation = new Animation(frameDuration, frames); this.numLoops = numLoops; if (numLoops == null || numLoops > 1) { rawAnimation.setPlayMode(PlayMode.LOOP); } this.state = state; setRegion(getCurrentFrame()); }
public Laser(boolean bad) { turnRed = bad; sprite = new Sprite(Game.gfxMgr.getTexture("test", "laser2_strip4.png")); sprite.setScale(0.25f, 7f); tween = Game.twnMgr.createTween(BounceTween.class, TweenType.OUT, 0.5f, -0.5f, 4f); TextureRegion[][] frames = TextureRegion.split(sprite.getTexture(), 16, 160); TextureRegion[] give = new TextureRegion[4]; for(int i = 0; i < 4; i++) { give[i] = frames[0][i]; } anim = new Animation(1/16f, give); anim.setPlayMode(PlayMode.LOOP); sprite.setRegion(anim.getKeyFrame(time)); }
public Background(AssetManager manager) { manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver())); manager.load(TEXTURE_FILENAME, Texture.class); manager.finishLoading(); texture = manager.get(TEXTURE_FILENAME); TextureRegion[] frames = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0]; animation = new Animation(0.1f, frames[0], frames[1], frames[2]); animation.setPlayMode(PlayMode.LOOP); setWidth(FRAME_WIDTH); setHeight(FRAME_HEIGHT); background = new TiledDrawable(animation.getKeyFrame(0f)); }
public GigaGalAssets(TextureAtlas atlas) { standingLeft = atlas.findRegion(Constants.STANDING_LEFT); standingRight = atlas.findRegion(Constants.STANDING_RIGHT); walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2); walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2); jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT); jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT); Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>(); walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2)); walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1)); walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2)); walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3)); walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP); Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>(); walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2)); walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1)); walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2)); walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3)); walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP); }
public void checkPrefs() { isUnlocked = pref.getBoolean(characterName, false); if (!isComingSoon) if (isUnlocked) if (lockDisplayed) { name = assetManager.get(characterName + "Name.png", Texture.class); description = assetManager.get(characterName + "Desc.png", Texture.class); textureRegion = new TextureRegion(assetManager.get(characterName + "-j.png", Texture.class)); animatedTextures = textureRegion.split(18, 22)[0]; animation = new Animation(period, animatedTextures); animation.setPlayMode(PlayMode.LOOP); sprite = new Sprite(assetManager.get(characterName + ".png", Texture.class)); sprite.setScale(scale); width = sprite.getWidth(); height = sprite.getHeight(); lockDisplayed = false; } }
public Player(float x, float y, float health, AssetManager assetManager) { super(x, y, health, assetManager); bounds = new Rectangle[2]; bounds[0] = new Rectangle(-20, 0, 8, 8); bounds[1] = new Rectangle(-20, 6, 18, 16); pref = Gdx.app.getPreferences("com.subzero.runners"); defaultCharacter = pref.getString("defaultCharacter", "Nikola"); texture = assetManager.get(defaultCharacter + ".png", Texture.class); textureRegion = new TextureRegion(assetManager.get(defaultCharacter + "-w.png", Texture.class)); animatedTextures = textureRegion.split(18, 22)[0]; animation = new Animation(period, animatedTextures); animation.setPlayMode(PlayMode.LOOP); textureRegion = new TextureRegion(assetManager.get(defaultCharacter + "-j.png", Texture.class)); animatedJumpTextures = textureRegion.split(18, 22)[0]; groundLevel = new Vector2(x, y); sprite = new Sprite(texture, 18, 22); sprite.setX(x); sprite.setY(y); }