Game Development Reference
In-Depth Information
Create a new file for the Clouds class and add the following code:
package com.packtpub.libgdx.canyonbunny.game.objects;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.packtpub.libgdx.canyonbunny.game.Assets;
public class Clouds extends AbstractGameObject {
private float length;
private Array<TextureRegion> regClouds;
private Array<Cloud> clouds;
private class Cloud extends AbstractGameObject {
private TextureRegion regCloud;
public Cloud () {}
public void setRegion (TextureRegion region) {
regCloud = region;
}
@Override
public void render (SpriteBatch batch) {
TextureRegion reg = regCloud;
batch.draw(reg.getTexture(), position.x + origin.x,
position.y + origin.y, origin.x, origin.y, dimension.x,
dimension.y, scale.x, scale.y, rotation, reg.getRegionX(),
reg.getRegionY(), reg.getRegionWidth(), reg.getRegionHeight(),
false, false);
}
}
public Clouds (float length) {
this.length = length;
init();
}
private void init () {
 
Search WWH ::




Custom Search