Jump to content

  • Log In with Google      Sign In   
  • Create Account

Individual File Animation

  • You cannot reply to this topic
5 replies to this topic

#1 Elshlivious   Members   -  Reputation: 101

Like
0Likes
Like

Posted Today, 12:25 AM

Not sure if this has been asked before, but I haven't been able to find any type of support of any kind in the past few days, so here I am.

 

What I would like to know, is how do you animate individual files in XNA? Currently I am using Cocos2D-XNA as a framework, and so far it's working pretty well, but it is not letting me animate individual files. 

 

I have these files that I need to animate together (and no I will NOT use a SpriteSheet):

- Walk_0

- Walk_1

- Walk_2

- Walk_3

 

How do I make it so that the framework animate these files; without them having to be SpriteSheet (that I completely 100% refuse to use.)?

 

What I've tried so far:

- List<Texture2D> with each file frame in it. Outcome: Game freezes then unfreezes once the last animation is shown.

- using a foreach statement. Outcome: freezes the game.

- using do/while statement. Outcome: freezes the game.

- using for statement. Outcome: freezes the game.



Sponsor:

#2 Nathan Drake   Members   -  Reputation: 590

Like
0Likes
Like

Posted Today, 12:42 AM

I'm not sure whether it works or not but as a suggestion, maybe you can set one texture2D as a reference and rewrite that every time you want to draw instead of changing the texture2D


Edited by Nathan Drake, Today, 12:44 AM.


#3 Elshlivious   Members   -  Reputation: 101

Like
0Likes
Like

Posted Today, 01:42 AM

I'm not sure whether it works or not but as a suggestion, maybe you can set one texture2D as a reference and rewrite that every time you want to draw instead of changing the texture2D

To be honest, that's what I am currently trying to do. The thing is that this framework has a function texture.InitWithTexture(<texture here>); But the thing is that it only allows you to name one texture at a time. It doesn't allow you to do texture = (texture here); at all. So I get what you are trying to suggest, but from what I've tried so far, it isn't possible. I do appreciate the help/suggestion.

 

I also just tried using a label to see if I can "goback" and reInit the texture with a different one, but all it does is the same thing as the for/foreach/do/while statements...I'm slowly running out of options. Unless someone happens to know of a tutorial out there about animation with individual files using DirectX or XNA. It can be in C++. I do know the language and can read it, I just prefer C# over C++.


Edited by Elshlivious, Today, 01:47 AM.


#4 L. Spiro   Crossbones+   -  Reputation: 22676

Like
0Likes
Like

Posted Today, 02:00 AM

- using a foreach statement. Outcome: freezes the game.
- using do/while statement. Outcome: freezes the game.
- using for statement. Outcome: freezes the game.

If you stop the game loop to go into your own loop over each of the frames then it only makes sense that the game loop would…stop.
Obviously you have to show one frame of animation per frame of the game (or so). That means not using a foreach/for/do-while/etc.
 

(and no I will NOT use a SpriteSheet)

Sprite sheets have absolutely nothing to do with the current problem, but in any case yes you will. You will use a sprite sheet (texture atlas) once you start to care about performance and memory.


L. Spiro


Edited by L. Spiro, Today, 02:01 AM.


#5 Elshlivious   Members   -  Reputation: 101

Like
0Likes
Like

Posted Today, 02:10 AM

 

- using a foreach statement. Outcome: freezes the game.
- using do/while statement. Outcome: freezes the game.
- using for statement. Outcome: freezes the game.

If you stop the game loop to go into your own loop over each of the frames then it only makes sense that the game loop would…stop.
Obviously you have to show one frame of animation per frame of the game (or so). That means not using a foreach/for/do-while/etc.
 

(and no I will NOT use a SpriteSheet)

Sprite sheets have absolutely nothing to do with the current problem, but in any case yes you will. You will use a sprite sheet (texture atlas) once you start to care about performance and memory.


L. Spiro

 

I' new to the Game Development field, so far I'm getting the hang of it except for animation I am having a hell of a lot of trouble with that. 

As for the SpriteSheet, no, I will never use them. Because all my assets are in a compressed .data file or how they call it, a resource file. So no, I won't.

As for the Looping, someone told me a while ago that it's possible to animate using loops like for/foreach/etc. I guess they were wrong then. How should I go about it then?


Edited by Elshlivious, Today, 02:10 AM.


#6 Norman Barrows   Crossbones+   -  Reputation: 4140

Like
0Likes
Like

Posted Today, 07:44 AM

a counter can be used to determine which frame to draw.

 

each time you render, you draw the appropriate frame, then increment the counter.

 

when you hit the last frame, stop the animation, or reset the counter to loop the animation.

 

loops can be used for stand alone or canned animations (IE cutscene animations) that pause the game and playback.


Edited by Norman Barrows, Today, 07:45 AM.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

 

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

 

 






PARTNERS