Diddy - request.

Monkey Forums/User Modules/Diddy - request.

Paul - Taiphoz(Posted 2014) [#1]
I may be wrong but at the moment FindSet will only grab long image strips, and will fail if your atlased animation is not in a single line.

Any chance we could get an overload so we can specify the images full width and height as well as each frames width and height so we can have atlased animations for example that are 3*3 rather than 9 in a row.

it's not a massive issue or anything just more a convenience thing, it's often easier to pack a square than a very long strip.


therevills(Posted 2014) [#2]
I've moved away from FindSet and implemented the SpriteAnimation class. This class allows you to specify which images you want for the animation itself. There is a SpriteAnimation now within the Sprite class.

For example:
Class Robot Extends Sprite
	Method New(gi:GameImage, x:Float, y:Float)
		Self.x = x
		Self.y = y
		Self.SetImage(gi)

		Local sa:SpriteAnimation = New SpriteAnimation(100)
		sa.Add(diddyGame.images.Find("rfall1"))
		sa.Add(diddyGame.images.Find("rfall2"))
		Self.spriteAnimations.Add("FALL", sa)
		Self.currentSpriteAnimation = sa
		
		sa = New SpriteAnimation(50)
		sa.Add(diddyGame.images.Find("rwalk1"))
		sa.Add(diddyGame.images.Find("rwalk2"))
		sa.Add(diddyGame.images.Find("rwalk3"))
		Self.spriteAnimations.Add("WALK", sa)

		sa = New SpriteAnimation(150)
		sa.Add(diddyGame.images.Find("rfly1"))
		sa.Add(diddyGame.images.Find("rfly2"))
		sa.Add(diddyGame.images.Find("rfly3"))
		sa.Add(diddyGame.images.Find("rfly4"))
		Self.spriteAnimations.Add("FLY", sa)
				
		Self.useSpriteAnimation = True
	End

	Method Update:Void()
		Local animFinish:Int = UpdateAnimation()
		if status = WALK Then currentSpriteAnimation = Self.spriteAnimations.Find("walk")
	End




Paul - Taiphoz(Posted 2014) [#3]
I am a little worried that your class would end up looking insane for really long animations, I have a mental image of 32 lines of nothing but add image 1 add image 2 ...... one of my games has a 120 frame animation that would be a nightmare.

you could write a function to handle it like this, grab a sequentially name set of images something like sa.Add(diddyGame.images.FindDeck("anim{n}",start_number,end_number) it would hide those needed 32...n lines of add image blah blah blah and hide them away in a loop which would be a lot less messy.

I really hope you do not abandon FindSet() tho, a lot of people are going to I think prefer to have their animations laid out in animation strips, either single row or multi row it makes then a lot easier to work with, I shudder at the thought of having 120 small images filling a dir just for a single animation, I know those would eventually be packed into an atlas but you still need access to them while your working and having them all out like that would be a pain.

It may just be me tho, lots of people in different ways, my vote would be placed of keeping both systems in the framework, give findset a little love so it can handle multi row strips and then leave it alone and work on your cool new animation class , then people get the best of both worlds, a flexibility and potentially dynamic animations system when they need it, or a quick and dependable frame strip systems when they want it.


Paul - Taiphoz(Posted 2014) [#4]
not even gona fix the spelling, its late im half awake .. just gona goto bed ..:) will edit and make my post more readable in the morning when I have had some sleep.


therevills(Posted 2014) [#5]
The FindSet isn't abandoned per say, its just that it doesn't work when using an Atlases well.

The reason why I created the SpriteAnimation class is that I use Texture Packer and to get the best "pack" it will place your images in different places and will mess up your neat animation strips.

With the above example of course you can just use a loop as long as you name your images correctly:
sa = New SpriteAnimation(150)
For Local i:Int = 1 to 4
	sa.Add(diddyGame.images.Find("rfly"+i))
Next
Self.spriteAnimations.Add("FLY", sa)


I add things to Diddy as and when I need stuff or if stuff doesn't quite work - I'm happy to add code other people write and find useful, it is open source after all :)


Paul - Taiphoz(Posted 2014) [#6]
I noticed with FindSet I had to offset the values a little as it was clipping a little of the next frame but it was a small and quick fix. I will have a look at some point and will shoot an issue/with code on the google code page.