Remove frame-margin #2

This commit is contained in:
2019-03-10 21:38:58 +01:00
parent 2a8477a919
commit a8e138e17d
3 changed files with 8 additions and 25 deletions

View File

@@ -22,9 +22,6 @@ Followed by a collection of definition lines, which always have a leading single
- Where `x` and `y` are unsigned integers.
- How much the frame needs to be translated every new frame.
- Usually identical to your frame-size, but useful for example for skipping every other frame.
- `frame-margin x y`
- Where `x` and `y` are unsigned integers.
- Represents the "empty space" between frames. A lot of spritesheets come with empty space between each sprite frame. This is to prevent frames bleeding into each other.
- `frame-count n`
- Where `n` is an unsigned integer.
- `frame-time n`
@@ -38,7 +35,7 @@ Followed by a collection of definition lines, which always have a leading single
The actual source code tells you most likely all you need to know:
```cpp
unsigned const x = frameOrigin.x + (frameNumber * frameMargin.x) + (frameNumber * frameStep.x);
unsigned const y = frameOrigin.y + (frameNumber * frameMargin.y) + (frameNumber * frameStep.y);
unsigned const x = frameOrigin.x + (frameNumber * frameStep.x);
unsigned const y = frameOrigin.y + (frameNumber * frameStep.y);
```
Where x and y are the topleft coordinates of the sprite frame.

View File

@@ -12,8 +12,8 @@ namespace Animation
if(reverse != bounced)
frameNumber = frameCount - (frameNumber + 1);
unsigned const x = frameOrigin.x + (frameNumber * frameMargin.x) + (frameNumber * frameStep.x);
unsigned const y = frameOrigin.y + (frameNumber * frameMargin.y) + (frameNumber * frameStep.y);
unsigned const x = frameOrigin.x + (frameNumber * frameStep.x);
unsigned const y = frameOrigin.y + (frameNumber * frameStep.y);
return sf::IntRect(x, y, frameSize.x, frameSize.y);
}
@@ -22,7 +22,6 @@ namespace Animation
: frameOrigin(0, 0),
frameSize(0, 0),
frameStep(0, 0),
frameMargin(0, 0),
frameCount(0),
frameTime(0),
reverse(false),
@@ -37,7 +36,6 @@ namespace Animation
"frame-origin",
"frame-size",
"frame-step",
"frame-margin",
"frame-count",
"frame-time",
"reverse",
@@ -88,27 +86,22 @@ namespace Animation
break;
case 3:
line >> candidate.frameMargin.x;
line >> candidate.frameMargin.y;
break;
case 4:
line >> candidate.frameCount;
break;
case 5:
case 4:
line >> candidate.frameTime;
break;
case 6:
case 5:
candidate.reverse = true;
break;
case 7:
case 6:
candidate.loop = true;
break;
case 8:
case 7:
candidate.loop = true;
candidate.bounce = true;
break;

View File

@@ -3,7 +3,6 @@
# frame-origin x y
# frame-size x y
# frame-step x y
# frame-margin x y
# frame-count n
# frame-time n
# reverse
@@ -14,7 +13,6 @@ animation default
frame-origin 0 15
frame-size 16 32
frame-step 16 0
frame-margin 0 0
frame-count 4
frame-time 32
loop
@@ -23,7 +21,6 @@ animation default-reverse
frame-origin 0 15
frame-size 16 32
frame-step 16 0
frame-margin 0 0
frame-count 4
frame-time 32
loop
@@ -33,7 +30,6 @@ animation default-fast
frame-origin 0 15
frame-size 16 32
frame-step 16 0
frame-margin 0 0
frame-count 4
frame-time 16
loop
@@ -42,7 +38,6 @@ animation carousel
frame-origin 0 15
frame-size 16 32
frame-step 2 0
frame-margin 0 0
frame-count 25
frame-time 16
@@ -50,7 +45,6 @@ animation carousel-reverse
frame-origin 0 15
frame-size 16 32
frame-step 2 0
frame-margin 0 0
frame-count 25
frame-time 16
reverse
@@ -67,7 +61,6 @@ animation carousel-bounce
frame-origin 0 15
frame-size 16 32
frame-step 2 0
frame-margin 0 0
frame-count 25
frame-time 32
bounce