Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Sprite Y Centering
Andrelvis
post Jan 18 2011, 04:39 PM
Post #1


Level 6
Group Icon

Group: Member
Posts: 84
Type: None
RM Skill: Undisclosed




Normally in RMVX, although the center of the width of a sprite is drawn in the center of a tile, the height is done differently - it is drawn from the bottommost part of a tile up. For RTP graphics this doesn't make any difference, since the bottommost part of the RTP chars is actually what should appear in the bottommost part of a tile.

But for some non-RTP sprites, that is an issue. For instance, if you wanted to make the tip of your char's sword spill over to the tile below or on top of him, normally that wouldn't be possible. Or you could want a large character graphic (say, an Ogre) to spill over equally to both the tiles below and on top of him, instead of spilling his extra size all over just the tile on top.

This script fixes that (and it is compatible with the RTP graphics as well to boot):

CODE
#Sprite Y Centering Script
#by Anakin_Starkiller

class Sprite_Character < Sprite_Base

  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_index != @character.character_index
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_index = @character.character_index
      if @tile_id > 0
        sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = Cache.character(@character_name)
        sign = @character_name[/^[\!\$]./]
        if sign != nil and sign.include?('$')
          @cw = bitmap.width / 3
          @ch = bitmap.height / 4
        else
          @cw = bitmap.width / 12
          @ch = bitmap.height / 8
        end
        self.ox = @cw / 2
        self.oy = @ch - ((@ch - 32) / 2) #for making character graphics appear correctly in the y center of the tile
      end
    end
  end
  
end
Go to the top of the page
 
+Quote Post
   
Resource Dragon
post Jan 19 2011, 06:21 AM
Post #2


Dragon has RAWR. So... RAWR.
Group Icon

Group: Local Mod
Posts: 984
Type: Developer
RM Skill: Masterful
Rev Points: 95




not that this isn't a good idea for a script, but it's possible to fix when your making the sprites.

You just have size the image correctly around the sprites. i've done this hundreds of times and they all line up correctly.
as long as its lined up correctly in the image, it's lined up correctly in the game.

i don't mean to sound rude or anything lol. sweat.gif but good job anyways on it.


__________________________
click me ->Signup for Digital Hijinks!<- click me
Go to the top of the page
 
+Quote Post
   
Andrelvis
post Jan 19 2011, 02:09 PM
Post #3


Level 6
Group Icon

Group: Member
Posts: 84
Type: None
RM Skill: Undisclosed




QUOTE (Prelude Dikter @ Jan 19 2011, 06:21 AM) *
not that this isn't a good idea for a script, but it's possible to fix when your making the sprites.

You just have size the image correctly around the sprites. i've done this hundreds of times and they all line up correctly.
as long as its lined up correctly in the image, it's lined up correctly in the game.

i don't mean to sound rude or anything lol. sweat.gif but good job anyways on it.


Thanks for the compliments.

There are some things that can't be done by correctly lining up the sprites; if you have parts of the sprite that you want to show below the character's feet, into the next tile, it can't be done normally.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 12:16 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker