How do Sprites and Animation work?

juggernaut

Veteran
Veteran
Joined
Dec 29, 2014
Messages
60
Reaction score
11
First Language
English
Primarily Uses
     So I might be getting a little ahead of myself here as I'm just working my way through DiamondandPlatinum's really great video tutorials.

     How are things like frames in a walk animation handled? 

     While I learn what I can about Ruby I keep my original art in mind and I know that I want some more fluid animations (something like 8 frames seems good). My goal in finding out how things work is to possibly save myself the heartache of drawing up tons and tons of high frame walks, sword slashes and the like, only to find out that I just can't use them. 

Is it possible to make composite sprites from two separate files?
 ​
     This one is probably a pipe dream but I'm trying to conceive a way that I could have a lot of arms and armor that would be essentially pasted onto the base bodies of sprites they will fit. If there isn't a way to do this the only option would be to draw X amount of characters a sheet for every single possible thing they could be wearing. Make sense?

As always, thanks for your time gang. 
 
Last edited by a moderator:

Heretic86

Veteran
Veteran
Joined
Nov 30, 2014
Messages
240
Reaction score
167
First Language
Engrish
Primarily Uses
The easiest way to explain Sprites is that the Characters are clipped parts of a single image.

In XP for example, we have 4 directions and 4 different Stepping Animation Frames.  4 x 4 = 16.  The way sprites work is to divide the whole image file down to clip off all the stuff that isnt properly representing the character at that time.  This concept works exactly the same for any animation.  Tilesets also use Sprites in Spriteset_Map.  It does the same thing and takes one large image and clips off anything that isnt your tile.  Battlers that arent animated can also be animated, but the image file is typically the entire sprite.

    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end

The end result is that sx and sy will both come out to be the top left corner of the character.  @cw and @ch are "character width" and "character height".  The @character.direction - 2) / 2 * @ch will change the Directions that appear on a numeric keypad, 2, 4, 6, 8 to 0, 1, 2, 3.  This is how the code determines what row and what column of the entire image will be displayed as your sprite character.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
1) explained above


2) you could, but you'd need to script that. I for one has a personal script which basically attaches and draws things above or below any character sprite. Currently using it to show wearables in the sprite.
 
Last edited by a moderator:

juggernaut

Veteran
Veteran
Joined
Dec 29, 2014
Messages
60
Reaction score
11
First Language
English
Primarily Uses
1) explained above

2) you could, but you'd need to script that. I for one has a personal script which basically attaches and draws things above or below any character sprite. Currently using it to show wearables in the sprite.
I imagine it'd be a nightmare to animate them as well
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Not really, you just animate them the same way the other characters are animated. So as long as you understand how the characters are animated, it becomes easy peasy. It's just like putting a character above/below another character. :)
 
Last edited by a moderator:

Heretic86

Veteran
Veteran
Joined
Nov 30, 2014
Messages
240
Reaction score
167
First Language
Engrish
Primarily Uses
Animations are not as difficult as you might think.  Basically, its just a Counter.  Each frame, the counter goes up by 1.  When it reaches a certain value, change the frame of animation.  Lots has to do with Move Speed.  All in all, it is the same for almost every animation, select the right frame from the sprite sheet at the indicated time.
 

juggernaut

Veteran
Veteran
Joined
Dec 29, 2014
Messages
60
Reaction score
11
First Language
English
Primarily Uses
Does anyone have a Where to Start tut or even a video so I can have a look at how it all works? Would be great to see someone import their own art and animate it, especially passing a 3 frame walk. If not, I will delve through the script editor and figure it out! Thanks :)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Animation just simply use sprite src_rect function and update the value.

You could try to put this snippet into your script editor

Code:
def updates  Graphics.update  Input.update  $sprite.src_rect.x += 1*32 if Graphics.frame_count % 5 == 0  $sprite.src_rect.x = 0 if $sprite.src_rect.x >= $sprite.bitmap.widthend $sprite = Sprite.new$sprite.bitmap = Cache.character("actor1")$sprite.src_rect = Rect.new(0,0,32,32)updates while true
 
Last edited by a moderator:

juggernaut

Veteran
Veteran
Joined
Dec 29, 2014
Messages
60
Reaction score
11
First Language
English
Primarily Uses
Animation just simply use sprite src_rect function and update the value.

You could try to put this snippet into your script editor

def updates Graphics.update Input.update $sprite.src_rect.x += 1*32 if Graphics.frame_count % 5 == 0 $sprite.src_rect.x = 0 if $sprite.src_rect.x >= $sprite.bitmap.widthend $sprite = Sprite.new$sprite.bitmap = Cache.character("actor1")$sprite.src_rect = Rect.new(0,0,32,32)updates while true
Alright! In the interest of this thread being in 'Learning RGSSX', care to explain how you perceive that snippet to work? I'll try playing with it of course but it helps to have a line by line explanation when you're learning
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Change this line

$sprite.src_rect.x += 1*32 if Graphics.frame_count % 5 == 0To this

$sprite.src_rect.x += 1And try to make a conclusion by yourself 
 

juggernaut

Veteran
Veteran
Joined
Dec 29, 2014
Messages
60
Reaction score
11
First Language
English
Primarily Uses
Necroing this thread which I only just divined was the source of my Deja Vu. 

So I'm now working on having a sprite that is minimum 64 tall, 32 wide. Frankly, I'd like to be substantially bigger than the chibi's but I'm beginning to see the limitations of that hope! Now then. I'd like to get my sprites into a walking animation that I have at about 8 frames, Any recommendations? The goal for the project is to have these higher frame, more fluid animations wherever possible. 
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
2. Yes you can do that easily with Events. You can put Events on top of each other and use them for Visual Eqipment or different Body Parts.

But you have to Event that the Body Part Events move when Player Moves. (But i tested it it works Bugfree).

1. You Char set got 3poses per direction, they are displayed 2 - 1 - 2 - 3 , so you get 3poses but they are animated like 4 in the good old xp^^.

You could also use the database animation tool and just display animation on char event when needed, like sword slash (with for example 15 frames/pictures +sounds and screen effects.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top