Progress on CannonHearth

This commit is contained in:
2015-09-17 16:11:58 +02:00
parent aa006a5c0b
commit 9c63975f2c
5 changed files with 30 additions and 8 deletions

View File

@@ -1,5 +1,9 @@
package de.samdev.cannonshooter.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import de.samdev.absgdx.framework.entities.Entity;
import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner;
import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry;
@@ -10,7 +14,6 @@ import de.samdev.cannonshooter.ZLayers;
public class CannonBarrel extends Entity {
private static final float ANIMATION_DURATION = 1000;
private float rotation = 0;
public CannonBarrel(Cannon owner) {
@@ -20,7 +23,7 @@ public class CannonBarrel extends Entity {
setZLayer(ZLayers.LAYER_CANNON_BARREL);
}
@Override
public void onActiveCollide(CollisionGeometryOwner passiveCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub

View File

@@ -1,5 +1,9 @@
package de.samdev.cannonshooter.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import de.samdev.absgdx.framework.entities.Entity;
import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner;
import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry;
@@ -8,6 +12,8 @@ import de.samdev.cannonshooter.Textures;
import de.samdev.cannonshooter.ZLayers;
public class CannonHearth extends Entity {
private static final Color COLOR_NEUTRAL = new Color(0.75f, 0.75f, 0.75f, 1f);
private float rotation = 0;
public CannonHearth(Cannon owner) {
@@ -18,6 +24,19 @@ public class CannonHearth extends Entity {
setZLayer(ZLayers.LAYER_CANNON_HEARTH);
}
@Override
public void render(SpriteBatch sbatch, ShapeRenderer srenderer) {
sbatch.setColor(COLOR_NEUTRAL);
renderTexture(sbatch, Textures.cannon_hearth[63], 0, 0);
sbatch.setColor(Color.RED);
renderTexture(sbatch, Textures.cannon_hearth[(int)(rotation/4f) % 64], 0, 0);
sbatch.setColor(Color.WHITE);
}
@Override
public void onActiveCollide(CollisionGeometryOwner passiveCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub
@@ -54,12 +73,12 @@ public class CannonHearth extends Entity {
@Override
public void beforeUpdate(float delta) {
rotation = (rotation + 360 - delta / 8) % 360;
rotation = (rotation + 360 + delta / 8) % 360;
}
@Override
public float getTextureRotation() {
return rotation;
return 0;//rotation;
}
@Override