Animation advice? [SOLVED]


(s corneil) #1

Hi guys,

I discovered FlashPunk a couple of weeks ago, and I decided to recreate a little game (http://www.andhalfafish.be/play/reachingForTheStars.php) to get to know the library.

So far, so good. (Thank you people responsible for FP : I like it a lot!)

But now I’m not quite sure how to proceed, so I thought I would ask you for advice. I want the player character to tap his foot when he is not moving around. I have read through some Q&A here on the forum … but I’m still not sure what to do.

Thanks for any help you can give me!

Edit : maybe I should mention that the body & the 2 feet are separate images … The way the animation was done with Unity, was to simply create an animation of the foot, and start the animation whenever it was needed. I’m not sure if I should do something similar in FP or not ???


(Martí Angelats i Ribera) #2

Probably the easiest way to do that is to create three different Entities (Entity class). Then give a Mask to the foots to detect when colides with the player. To move them you can simply modify the x and y parameters.

I actually recomend you to follow some tutorials wich you can find in this forum. There are a really good ones to start.


(s corneil) #3

I would be very happy if you could point me to some relevant tutorials ?

I have worked through all tutorials I could find (the ‘getting started’ ones) & I have spent quite some time searching this forum. But maybe there are other tutorials that I missed ?

I’m not a 100% sure I understand your explanation … (I have some programming experience, but not with AS & FP :frowning: ). Are you saying I can somehow ‘link’ the different entities ? (I need to check ‘Mask’ … I have not used that before)

I was thinking I should create a spritesheet for the foot animation & have my cat-entity (the body) use 2 graphics (body + foot). Is that even possible ???


(Martí Angelats i Ribera) #4

What you have to know is that FP works using worlds, cameras (one for each world) and entities (even if you only want to add a graphic you’ll add an entity).

You can fins the basic documentation here.

If you still don’t find ansewers i’ll show you how to do it (maybe creating a tutorial for new people ;))


(Ben Pettengill) #5

There’s no reason to have each foot as a separate Entity. It would be easier to just add your player’s 3 main graphics (body and 2 feet) to a single GraphicList, and use the GraphicList as your entity’s graphic:

public class Player extends Entity
{
	private var FootL:Image = new Image(foot_left);
	private var FootR:Image = new Image(foot_right);
	private var Body = new Image(body);

	private var drawlist:Graphiclist = new Graphiclist();


		public function Player() 
		{
			drawlist.add(FootL);
			drawlist.add(FootR);
			drawlist.add(Body);
			graphic = drawlist;
			FootL.x = 10; FootL.y = 50;
			FootR.x = 40; FootR.y = 50;
			FootL.originX = 5; FootL.originY = 5;				
			.
			.
			.
		}
}

This way, all the player’s graphics will move relative to where the player is. Each graphic can even have its own position and origin relative to its parent entity.

A “Mask” is what Flashpunk uses to check for collisions between entities. It can be as simple as a rectangle (or Hitbox), or be a pixel-perfect representation of the sprite (a Pixelmask). If you’re just getting started, a Hitbox will probably be good enough.

You could create a Spritemap to animate the feet frame by frame, but if you just want to use rotation like you did in the Unity game, Images in Flashpunk have an angle property. You could then use a Tween to smoothly change the angle of the foot every 1/2 or 1/4 of a second. This thread gives pretty good examples of all the Tween functions that Flashpunk has to offer (the AngleTween is at the bottom of the first post).

Anyway, I hope that helps. I could post some more specific examples if you like.


(Martí Angelats i Ribera) #6

I missunderstood what he wanted to do. Sorry about that.


(s corneil) #7

No worries ! :slight_smile: Thank you both very much for your help.

@pgil : Exactly what I was looking for !