The Wayback Machine - https://web.archive.org/web/20201012100626/https://github.com/Valkryst/V2DSprite
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 

README.md

CircleCI Release Total alerts Language grade: Java

Jar Files & Maven

The Maven dependency is hosted off of JitPack, so you will need to add JitPack as a repository before you add V2DSprite as a dependency.

Maven

JitPack:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Dependency:

<dependency>
    <groupId>com.github.Valkryst</groupId>
    <artifactId>V2DSprite</artifactId>
    <version>2020.04.05-break</version>
</dependency>

Jar

Jar files can be found on the releases page.

Loading a SpriteSheet

To load a SpriteSheet from the filesystem, you could use the following code.

final Path imagePath = Paths.get("./test_res/image.png");
final Path jsonPath = Paths.get("./test_res/data-valid.json");
final SpriteSheet spriteSheet = new SpriteSheet(imagePath, jsonPath);

To load a SpriteSheet from within the JAR, you can use the following code.

final Path imagePath = Paths.get(ClassName.class.getResource("./image.png").toURI());
final Path jsonPath = Paths.get(ClassName.class.getResource("./data-valid.png").toURI());
final SpriteSheet spriteSheet = new SpriteSheet(imagePath, jsonPath);

Defining a SpriteSheet

The Sprites of a SpriteSheet are defined VIA an array of JSON objects.

  • name - A unique ID for the sprite.
    • Capital letters are ignored, so the words "Yellow", "YeLLoW", and "yellow" are all considered to be the same.
  • x - The x-axis position of the Sprite's top-left pixel, within the SpriteSheet.
  • y - The y-axis position of the Sprite's top-left pixel, within the SpriteSheet.
  • width - The width of the Sprite, in pixels.
  • height - The height of the Sprite, in pixels.
[
    {
        "name": "Sprite A",
        "x": 0,
        "y": 0,
        "width": 32,
        "height": 32
    },
    {
        "name": "Sprite B",
        "x": 32,
        "y": 0,
        "width": 32,
        "height": 32
    },
    {
        "name": "Sprite C",
        "x": 0,
        "y": 32,
        "width": 32,
        "height": 32
    },
    {
        "name": "SpriteD",
        "x": 32,
        "y": 32,
        "width": 32,
        "height": 32
    }
]
You can’t perform that action at this time.