Animated Barrel

This commit is contained in:
Mike Schwörer 2015-09-17 14:37:44 +02:00
parent 3be4b2cab2
commit f1cd7f4099
8 changed files with 40 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,12 +1,15 @@
package de.samdev.cannonshooter;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import de.samdev.absgdx.framework.util.TextureHelper;
public final class Textures {
public static Texture texbackground;
public static Texture cannon_body;
public static Texture cannon_barrel;
public static TextureRegion[] cannon_barrel;
public static Texture cannon_hearth;
public static Texture cannon_bullet;
@ -14,6 +17,6 @@ public final class Textures {
texbackground = new Texture("level_background.png");
cannon_body = new Texture("cannon_body.png");
cannon_barrel = new Texture("cannon_barrel.png");
cannon_barrel = TextureHelper.load1DArray("cannon_barrel.png", 512, 256, 16);
}
}

View File

@ -8,11 +8,13 @@ import de.samdev.cannonshooter.Textures;
import de.samdev.cannonshooter.ZLayers;
public class CannonBarrel extends Entity {
private static final float ANIMATION_DURATION = 2000;
private float rotation = 0;
public CannonBarrel(Cannon owner) {
super(Textures.cannon_barrel, 4, 2);
super(Textures.cannon_barrel, ANIMATION_DURATION, 4, 2);
setPosition(owner.getPositionX() - 1, owner.getPositionY());
@ -61,7 +63,7 @@ public class CannonBarrel extends Entity {
@Override
public float getTextureRotation() {
return rotation;
return 0;
}
@Override

View File

@ -0,0 +1,30 @@
<Query Kind="Program">
<Namespace>System.Drawing</Namespace>
<Namespace>System.Drawing.Imaging</Namespace>
</Query>
void Main()
{
Image input = Image.FromFile(@"F:\Eigene Dateien\Dropbox\Programming\Java\workspace\Cannon Shooter\data\cannon_barrel_single.png");
Image output = new Bitmap(input.Width * 4, input.Height * 4, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(output))
{
for (int x = 0; x < 4; x++)
{
for (int y = 0; y < 4; y++)
{
int idx = y*4 + x;
g.DrawImageUnscaledAndClipped(input, new Rectangle(input.Width * x, input.Height * y, input.Width - idx * 8 - 22, input.Height));
g.DrawImage(input, new Rectangle(input.Width * (x+1) - idx * 8 - 22, input.Height * y, 22, input.Height), new Rectangle(input.Width - 22, 0, 22, input.Height), GraphicsUnit.Pixel);
}
}
}
output.Dump();
output.Save(@"F:\Eigene Dateien\Dropbox\Programming\Java\workspace\Cannon Shooter\android\assets\cannon_barrel.png");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.