Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline scrappy.doo  
#1 Posted : Thursday, February 14, 2013 1:54:35 PM(UTC)
scrappy.doo

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?

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Cr3dos  
#2 Posted : Thursday, February 14, 2013 11:19:22 PM(UTC)
Cr3dos

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

Offline Benjamin  
#3 Posted : Friday, February 15, 2013 4:06:02 AM(UTC)
Benjamin

Medals: Admin

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.
Offline scrappy.doo  
#4 Posted : Friday, February 15, 2013 1:53:29 PM(UTC)
scrappy.doo

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 ThumpUp

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

Offline Cr3dos  
#5 Posted : Friday, February 15, 2013 8:44:54 PM(UTC)
Cr3dos

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

Offline scrappy.doo  
#6 Posted : Saturday, February 16, 2013 10:22:13 AM(UTC)
scrappy.doo

Joined: 2/8/2013(UTC)
Posts: 4

I pasted my complete class to pastebin: http://pastebin.com/z4JqM8fG

Here'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: UserPostedImage
Offline scrappy.doo  
#7 Posted : Monday, March 25, 2013 5:27:19 PM(UTC)
scrappy.doo

Joined: 2/8/2013(UTC)
Posts: 4

Originally Posted by: Benjamin Nitschke Go to Quoted Post
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?

Offline Benjamin  
#8 Posted : Monday, March 25, 2013 6:24:56 PM(UTC)
Benjamin

Medals: Admin

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.
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
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.

Powered by YAF.NET | YAF.NET © 2003-2022, Yet Another Forum.NET
This page was generated in 0.083 seconds.