[RESOLVED]Idle Animation...

Started by Calintz, January 31, 2009, 10:36:09 pm

Previous topic - Next topic

Calintz

January 31, 2009, 10:36:09 pm Last Edit: February 02, 2009, 12:14:13 am by Calintz16438
I was wondering if someone could make a script that will add animation to characters when you aren't moving them.

EX.
- Hair blowing in the wind
- Blinking

Landith


Calintz


Landith

Okay, this is what I have so far...
It doesn't work though.

Spoiler: ShowHide
class Game_Player
 
  attr_accessor :character_name_org
  attr_accessor :character_name
  def initialize
    super
    @character_name_org = @character_name
  end
  def update
    unless self.moving?
      @character_name = @character_name_org + '_idl'
      update_idle
    end
  end
  def update_idle
    if self.moving?
      @character_name = @character_name_org
      update
    end
  end
end


Someone can take over because I thought it would be easy but i was wrong...  :<_<:
Sorry Calintz...

winkio

January 31, 2009, 11:20:30 pm #4 Last Edit: January 31, 2009, 11:24:58 pm by winkio
wait, isn't this a built-in function of rmxp?  I'm pretty sure... lemme check...

EDIT: Yes, ok, I think I found it.  Setting a character's step_anime property to true should give it idle animation.  Hence, you code would look something like:

@character_name.step_anime = true

Yes, that should be it...

Landith

Are you talking about idle sprites?

Idle sprites aren't a built in RMXP Function, although it would have been nice to have...

@Calintz: I think you can use Blizz-ABS with it being compatible with your side-view system and use the sprite handling it uses without configuring anything else. I'm not sure though...

winkio

January 31, 2009, 11:25:42 pm #6 Last Edit: January 31, 2009, 11:30:06 pm by winkio
I edited my earlier post with it.

And... yes, they are built in.  Unless we are talking about two different types of idle sprites...

Oh, I get it.  you want to switch between two different sprites, am i correct?  One for idle, and one for movement?  Yeah, that's not built in...  I just thought you were talking about animating a sprite in place. :stupid:

Calintz

Yeah...switch between two separate sprites...

I didn't think it would be that hard actually...I thought it would just consist of something like if player is moving, then it would use one, but if no buttons are being pressed it would search the specified folder for a certain image and animate it...

I guess I was wrong, Lol...
Thanks anyway Landith!

Blizzard

Just check out how I did it in Blizz-ABS. It's all in BlizzABS::Controller and Map_Battler.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

I don't know ANYTHING about scripting sadly...

Blizzard

I meant winkio and Landith. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

winkio

oh, fine, ill do it...  Give me a few minutes...

Calintz

Lol, you don't have to!!

- This IS a REQUEST!! I'm not picky, Lol

winkio

February 01, 2009, 02:55:38 pm #13 Last Edit: February 01, 2009, 03:01:04 pm by winkio
lol 48 lines!  It goes below defaults, above main, and just name your idle sprites the same as the character sprite with _idl on the end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  With idle sprites.  name the idle sprites the same as their normal ones
#  except with '_idl' on the end (before the extension)
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :character_name_org       # original character file name
  attr_reader   :current_sprite           # current sprite suffix
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_idlesprites_before initialize
  def initialize
    initialize_idlesprites_before
    # set original character name
    @character_name_org = @character_name
    # set current sprite
    @current_sprite = ""
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_idlesprites_before update
  def update
    update_idlesprites_before
    if @character_name != ""
      if moving?
        if @current_sprite != ''
          @step_anime = false
          @character_name = @character_name_org
          @current_sprite = ''
        end
      else
        if @current_sprite != '_idl'
          @character_name_org = @character_name
          @step_anime = true
          @character_name += '_idl'
          @current_sprite = '_idl'
        end
      end
    end
  end
end


I tested it and it worked fine.  An example of naming would be:
moving sprite: MainDude.png
idle sprite:     MainDude_idl.png

Calintz

February 01, 2009, 03:22:42 pm #14 Last Edit: February 01, 2009, 03:25:29 pm by Calintz16438
Your a beast...
I will test it now =)

I know this is a small scriplet type thing, but you should make a quick demo and add it to the scripts section.

*powers up*

Blizzard

I think it has a bug - the same bug mine had when I made the first version.
The short moment where you are fully standing on a map square, even though you are pressing a movement button, would display the idl sprite for one short moment. I fixed this by adding "&& Input.dir4 == 0" (actually it was Input.dir8, lol) to the "moving?" condition. You should try out the script if it works normally. If it does, then this fix is unecessary.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

I will look for that bug now...

Landith

Good job Winkio!

*Powers Up*

I wish I could script...  :(

Calintz

Well...it's not working the way I wanted...

The sprite is idle, but just doing a moving animation. I have created a quick sprite alter that makes the character blink, but he isn't blinking, he is just moving in place...

winkio

February 01, 2009, 05:21:04 pm #19 Last Edit: February 01, 2009, 05:35:26 pm by winkio
Err, mine works fine.  Here, I'll put up a demo in a bit.

@Blizz: thanks for that.  I didn't test with a drastically different sprite so i didn't notice :).

Ok, here's the demo.  The idle animations are stupid, but that's all i could come up with in about 15 seconds.

http://www.sendspace.com/file/u8lbfo

recopy the slightly-fixed version out of there.

ignore the other random left-over stuff in the demo.