Joined: 2/8/2013(UTC) Posts: 4
|
Just fiddling around with the engine a bit and trying to understand the basics. I managed to show a sprite on screen and control is with the arrow keys, so that's awesome, but how do animated sprites work? Is there an example anywhere that shows animated sprites?
|
|
|
|
Joined: 8/22/2011(UTC) Posts: 61 Location: Switzerland
Was thanked: 4 time(s) in 4 post(s)
|
Hi scrappy.doo The DeltaEngine doesn't provide this feature. I don't know if they will add this in the future. I created a little test project for an AnimatedSprite based on a sprite sheet, but unfortunately it does not work correctly. It displays the wrong section of the sprite sheet. I uploaded the project on my dropbox. You can have a look at it and maybe you find the bug or somebody else does. I will also continue to investigate and when the bug is fixed I will also implement the animation for a rotated sprite :-) kind regards, Dominik Edited by user Thursday, February 14, 2013 11:23:06 PM(UTC)
| Reason: Not specified
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
We have removed AnimatedSprite support in Milestone 2, but will add it again quite soon. Most Game Jam games from last week added some form of animation themselves, and I guess everyone found a different solution like Dominik did.
I have written this down as a feature request for next week. This weeks release will be mostly just bugfixes.
|
|
|
|
Joined: 2/8/2013(UTC) Posts: 4
|
I've also implemented my own version of animatedsprite, but I liked the version of Dominik better for a starting point So I've fixed his version. Mind you that this version takes 0,0 as the first column/row instead of 1/1: Code:
private void DrawImage()
{
float rowPercentageForOneImage = 1 / image.PixelSize.Height * height;
float columnPercentageForOneImage = 1 / image.PixelSize.Width * width;
Point topLeft = new Point(currentImage.X * columnPercentageForOneImage, currentImage.Y * rowPercentageForOneImage);
Point topRight = new Point((currentImage.X+1) * columnPercentageForOneImage, currentImage.Y * rowPercentageForOneImage);
Point botLeft = new Point(currentImage.X * columnPercentageForOneImage, (currentImage.Y + 1) * rowPercentageForOneImage);
Point botRight = new Point((currentImage.X + 1) * columnPercentageForOneImage, (currentImage.Y + 1) * rowPercentageForOneImage);
var vertices = new[]
{
GetVertex(DrawArea.TopLeft, topLeft),
GetVertex(DrawArea.TopRight, topRight),
GetVertex(DrawArea.BottomRight, botRight),
GetVertex(DrawArea.BottomLeft, botLeft)
};
image.Draw(vertices);
}
}
Edited by user Friday, February 15, 2013 1:56:17 PM(UTC)
| Reason: Not specified
|
|
|
|
Joined: 8/22/2011(UTC) Posts: 61 Location: Switzerland
Was thanked: 4 time(s) in 4 post(s)
|
hmm for me it doesn't fix it at all. It shows some of the animation parts split in the diagonal. Edit: I uploaded a new version with some changes for readability: switched x and y which makes more sense. -1 instate of -PercentageForOneImage Edited by user Friday, February 15, 2013 8:55:42 PM(UTC)
| Reason: Not specified
|
|
|
|
Joined: 2/8/2013(UTC) Posts: 4
|
I pasted my complete class to pastebin: http://pastebin.com/z4JqM8fGHere's an example on how to use it: Code:
Point[] redFrames = new Point[] { new Point(1, 0), new Point(2, 0), new Point(3, 0), new Point(4, 0) };
var red = new AnimatedSprite(content.Load<Image>("red"),Rectangle.FromCenter(0.5f, 0.5f, 0.16f, 0.16f), Color.White, 32, 32, 4, redFrames);
renderer.Add(red);
And an example spritesheet: 
|
|
|
|
Joined: 2/8/2013(UTC) Posts: 4
|
Originally Posted by: Benjamin Nitschke  We have removed AnimatedSprite support in Milestone 2, but will add it again quite soon. Most Game Jam games from last week added some form of animation themselves, and I guess everyone found a different solution like Dominik did.
I have written this down as a feature request for next week. This weeks release will be mostly just bugfixes. Any update on the animated sprite feature of the engine?
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
Good question, as far as I know animated sprites have been implemented and are approved, so they should be available in the next update.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.