collapse collapse

 Community


 User Info




Willkommen Gast. Bitte einloggen oder registrieren.

 Partnerseiten

rpgvx.net

Das Forum ist offline

Autor Thema: + [ Sprite Mover ] +  (Gelesen 1886 mal)

woratana

  • Gast
+ [ Sprite Mover ] +
« am: Juni 11, 2008, 07:49:24 »
Sprite Mover
Version 1.0
by Woratana
Release Date: 02/06/2008


Introduction
This is a little snippet I wrote for my project.
It's to fix the problem that sprite is too high or too low for the tiles behind.

I actually ran into this problem when I'm trying to put stuffs in 1 block height of cave's ground.
So I think to use script is easier than edit the sprite image~ :D

Enjoy~  :lol:


Screenshots

The red fire use Sprite Mover, the blue fire doesn't~


Script
Place it above main

Spoiler for Hiden:
#===============================================================
# ? [VX Snippet] ? Sprite Mover ? ?
# * Move sprite in pixel to get right location~ *
#--------------------------------------------------------------
# ? by Woratana [woratana@hotmail.com]
# ? Thaiware RPG Maker Community
# ? Released on: 02/06/2008
# ? Version: 1.0
#--------------------------------------------------------------

#==================================================================
# ** HOW TO USE **
#-----------------------------------------------------------------
# * In the event page that you want to move sprite, add comment:
#  MOVE x_plus, y_plus
# ** x_plus: how many pixel you want to move sprite horizontally
# (- number: move left | + number: move right)
# ** y_plus: how many pixel you want to move sprite vertically
# (- number: move up | + number: move down)

# * For example, add comment:
#  MOVE 0, -20
# ** to move sprite up 20 pixel~
#==================================================================


class Game_Event < Game_Character
  attr_accessor :spr_move
  alias wora_mover_gameve_setup setup
  
  def setup(*args)
    wora_mover_gameve_setup(*args)
    mover = comment?('MOVE', true)
    if !mover[0]
      @spr_move = nil
    else
      @spr_move = @list[mover[1]].parameters[0].clone
      @spr_move.sub!('MOVE','').gsub!(/\s+/){''}
      @spr_move = @spr_move.split(',')
      @spr_move.each_index {|i| @spr_move[i] = @spr_move[i].to_i }
    end
  end
  
  def comment?(comment, return_index = false )
    if !@list.nil?
      for i in 0...@list.size - 1
        next if @list[i].code != 108
        if @list[i].parameters[0].include?(comment)
          return [true, i] if return_index
          return true
        end
      end
    end
    return [false, nil] if return_index
    return false
  end
end

class Sprite_Character < Sprite_Base
  alias wora_mover_sprcha_upd update
  
  def update
    wora_mover_sprcha_upd
    if @character.is_a?(Game_Event) and !@character.spr_move.nil?
      self.x = @character.screen_x + @character.spr_move[0]
      self.y = @character.screen_y + @character.spr_move[1]
    end
  end
end


Instruction
In the event page that you want to move sprite, add comment:
Zitat
MOVE x_plus, y_plus

** x_plus: how many pixel you want to move sprite horizontally
(- number: move left | + number: move right)
** y_plus: how many pixel you want to move sprite vertically
(- number: move up | + number: move down)

For example, add comment:
Zitat
MOVE 0, -20

to move sprite up 20 pixel~


Author's Notes
Free for use in your work if credit is included.


Bug Report?
Please give me these informations:
Zitat
- What is it says in error window?
- When is it get error? (Right after run game, when you choose something, etc.)
- Do you have any other scripts running in your game that may crash with this script?

+ [ Sprite Mover ] +

Caith

  • Gast
+ [ Sprite Mover ] +
« Antwort #1 am: Juni 11, 2008, 08:07:46 »
hey it works great.
no more speciel edits for TileE^^

if a thanks button would be here, you could be sure that i press it.

(If it dont work with other scripts, i will post it.)
« Letzte Änderung: Juni 11, 2008, 08:08:14 von Caith »

+ [ Sprite Mover ] +

Offline Hanmac

  • true = false
  • Database-Verunstalter
  • **
  • Beiträge: 138
+ [ Sprite Mover ] +
« Antwort #2 am: Juni 11, 2008, 08:16:58 »
i think you can use a rgex ala /MOVE \d+,\d+/
"alles ist wahr, wenn wahr einen bestimmten Wert annimmt."

+ [ Sprite Mover ] +

woratana

  • Gast
+ [ Sprite Mover ] +
« Antwort #3 am: Juni 11, 2008, 08:49:21 »
@Caith
Thanks! :)I'm glad you like it.

@Hanmac
String is easier for everyone who are learning how to script. :D
+ I'm not good at regexp. So this is also easier to me~
« Letzte Änderung: Juni 11, 2008, 08:51:05 von woratana »

+ [ Sprite Mover ] +

Offline Hanmac

  • true = false
  • Database-Verunstalter
  • **
  • Beiträge: 138
+ [ Sprite Mover ] +
« Antwort #4 am: Juni 11, 2008, 09:16:22 »
after work i make this.
"alles ist wahr, wenn wahr einen bestimmten Wert annimmt."

+ [ Sprite Mover ] +

woratana

  • Gast
+ [ Sprite Mover ] +
« Antwort #5 am: Juni 11, 2008, 09:19:19 »
What did you made?

Sorry, I am pretty confuse in your English. :P
« Letzte Änderung: Juni 11, 2008, 09:19:49 von woratana »

+ [ Sprite Mover ] +

Offline KeksX

  • VX-Kenner
  • ****
  • Beiträge: 490
  • &so...Ne?
+ [ Sprite Mover ] +
« Antwort #6 am: Juni 11, 2008, 09:28:31 »
i think that he meant:"  i'll try this after work" ...xD

Anyways:
Great script!
« Letzte Änderung: Juni 11, 2008, 09:28:45 von KeksX »
[...]und da gilt meist, wer kommt, malt zuerst[...]

 


 Bild des Monats

rooftop party

Views: 3581
By: papilion

 Umfrage

  • Wer soll das BdM gewinnen?
  • Dot Kandidat 1
  • 3 (25%)
  • Dot Kandidat 2
  • 1 (8%)
  • Dot Kandidat 3
  • 2 (16%)
  • Dot Kandidat 4
  • 0 (0%)
  • Dot Kandidat 5
  • 6 (50%)
  • Stimmen insgesamt: 12
  • View Topic

 Schnellsuche





SimplePortal 2.3.3 © 2008-2010, SimplePortal