Back to project page SpaceGame.
The source code is released under:
Copyright (c) 2012 ??ukasz Patalas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the So...
If you think the Android project SpaceGame listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.lpatalas.spacegame; /*from w w w .ja va2 s .co m*/ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; class CloudLayer { private final Color color; private float scroll; private final float scrollSpeed; private final Texture texture; public CloudLayer(String textureName, float scrollSpeed, Color color) { this.color = color; this.scrollSpeed = scrollSpeed; this.texture = createTexture(textureName); } private Texture createTexture(String textureName) { Texture texture = new Texture(Gdx.files.internal(textureName)); texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); texture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat); return texture; } public void move(float deltaTime) { scroll -= deltaTime * scrollSpeed; if (scroll < -1.0f) { scroll += 1.0f; } } public void render(SpriteBatch spriteBatch) { spriteBatch.setColor(color); float u1 = -scroll; float v1 = 0; float u2 = -scroll + 1.0f; float v2 = 1.0f; spriteBatch.draw(texture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), u1, v1, u2, v2); } }