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
> ~[Cursor Sprite + Cursor Smooth Movement Script]~v.1.2, by strcat
YanXie
post Apr 21 2008, 06:20 PM
Post #1


Because Tomorrow Will Surely Come...
Group Icon

Group: Revolutionary
Posts: 1,137
Type: None
RM Skill: Skilled




Cursor Sprite + Cursor Smooth Movement Script

Version 1.2
Author strcat
Release Date 29 / 01 / 2008

Introduction

Well,I found this script a long time,but never feel like posting this here,but since Wora suggest me to post it,I'll just post this D:


Features

1.Create a cursor sprite for Window_Selectable class.

2.Enable smooth movement of cursor.

Script

Download from the text file below :

[attachment=631:Cursor_S...t_Script.txt]

or copy from the codebox below :

[Show/Hide] Cursor Sprite + Smooth Movement Script
CODE
#==============================================================================
# Cursor Sprite + Smooth Movement Script
#==============================================================================
# Author  : strcat
# Version : 1.2
# Date    : 29 / 01 / 2008
#------------------------------------------------------------------------------
# This script will create a new cursor sprite,and add a smooth movement to
# the cursor,thus making your game look better happy.gif
#------------------------------------------------------------------------------
#==============================================================================
# ** STRRGSS2
#==============================================================================
module STRRGSS2
  # Cursor graphic file name
  WCURSOR_FN = "Window_cursor"
  # position of the cursor(x, y)
  WCURSOR_X = 0
  WCURSOR_Y = 0
end
class Sprite_WindowCursor < Sprite
  WAIT = 8    # numbers of frame for cursor update delay.
  CW   = 24   # cursor width
  CH   = 24   # cursor height
end
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  #  * Update Cursor
  #--------------------------------------------------------------------------
  def update_se_cursor
    cr = self.cursor_rect
    r = Rect.new(0, 0, 0, 0)
    y = (self.cursor_rect.height - 24) / 2
    v = nil
    v = self.viewport if self.viewport != nil
    @strcursor.viewport = v
    @strcursor.x = self.x + 16 + cr.x - 24 + STRRGSS2::WCURSOR_X
    @strcursor.y = self.y + 16 + cr.y + y  + STRRGSS2::WCURSOR_Y
    @strcursor.z = self.z + 16
    @strcursor.opacity += 64
    @strcursor.opacity = self.opacity if @strcursor.opacity > self.opacity
    @strcursor.visible = ((cr != r) and self.openness == 255)
    @strcursor.visible = false unless self.visible
    @strcursor.blink = (not self.active)
    @strcursor.update
  end
  def update_cursor_str(r,rect)
    self.cursor_rect = r
    rect = Rect.new(0, 0, 0, 0) if @index < 0
    mx = self.cursor_rect.x - rect.x
    if mx >= -1 and mx <= 1
      self.cursor_rect.x = rect.x
    elsif mx != 0
      x = self.cursor_rect.x - (mx/2.0)
      self.cursor_rect.x = x
    end
    my = self.cursor_rect.y - rect.y
    if my >= -1 and my <= 1
      self.cursor_rect.y = rect.y
    elsif my != 0
      y = self.cursor_rect.y - (my/2.0)
      self.cursor_rect.y = y
    end
    self.cursor_rect.width = rect.width
    self.cursor_rect.height = rect.height
  end
  def visible=(v)
    super
    @strcursor.visible = v
  end
  def active=(v)
    super
    @strcursor.visible = false
  end
  def dispose
    @strcursor.dispose
    super
  end
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_str05m initialize
  def initialize(x, y, width, height, spacing = 32)
    initialize_str05m(x, y, width, height, spacing)
    file = STRRGSS2::WCURSOR_FN
    v = nil
    v = self.viewport if self.viewport != nil
    @strcursor = Sprite_WindowCursor.new(file, v)
    @f_set = false
  end
  alias update_str05m update
  def update
    update_se_cursor unless @opening
    update_str05m
  end
  alias update_cursor_str05m update_cursor
  def update_cursor
    r = self.cursor_rect.clone unless @f_set
    update_cursor_str05m
    update_cursor_str(r, self.cursor_rect.clone) unless @f_set
    @f_set = false
  end
  #--------------------------------------------------------------------------
  # * Get Index
  #--------------------------------------------------------------------------
  def index=(index)
    @f_set = true
    @index = index
    update_cursor
    call_update_help
  end
end
#==============================================================================
# ** Sprite_WindowCursor
#==============================================================================
class Sprite_WindowCursor < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :blink
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(name,viewport)
    super(viewport)
    self.bitmap = Cache.system(name)
    self.src_rect.set(0, 0, CW, CH)
    self.opacity = 0
    @xx = -8
    @wait = WAIT
    @count = 0
    @blink = false
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    @xx += 1 if @xx != 0
    self.x += @xx
    @count += 1
    self.visible = false if @blink and (@count % 4) == 0
    @wait -= 1
    return if @wait > 0
    @wait = WAIT
    self.src_rect.x += CW
    self.src_rect.x = 0 if (self.bitmap.width <= self.src_rect.x)
  end
end



Customization

Line 15 to 19 :

CODE
  # Cursor graphic file name
  WCURSOR_FN = "Window_cursor"
  # position of the cursor(x, y)
  WCURSOR_X = 0
  WCURSOR_Y = 0


1.Change "Window_cursor" to the file name that you use for the cursor sprite graphic

2.Change the value WCURSOR_X for the cursor's X-coordinate.

3.Change the value WCURSOR_Y for the cursor's Y-coordinate.

Compatibility

Unknown

Screenshot



DEMO

Not needed.

Installation

Copy and paste it in a new script page under "Material" section.

FAQ

None.

Terms and Conditions

Credit to strcat if you use this script.

(*゚ノO゚)<オオオオォォォォォォォーーーーーイ!

cheers,puppeto4 smile.gif


__________________________
how make teleport to graveyard then your character die?

AWAY FOR VACATION.
NOT HERE UNTIL JAN/FEB 2010 -w-/
Go to the top of the page
 
+Quote Post
   
woratana
post Apr 21 2008, 06:41 PM
Post #2


Looking for scripter to hire? PM me *O*
Group Icon

Group: +Gold Member
Posts: 1,038
Type: Scripter
RM Skill: Undisclosed




Good stuff, puppeto.

Thanks for posting it here. wink.gif


__________________________
Check out my NEW blog!!!



MVP (Most Valuable Poster) Award 2008


Go to the top of the page
 
+Quote Post
   
Zinos666
post Apr 23 2008, 11:47 PM
Post #3


Level 7
Group Icon

Group: Revolutionary
Posts: 105
Type: Event Designer
RM Skill: Advanced




I can't use this without the Window_cursor.

-=edit=-
Never mind I made one.

This post has been edited by Zinos666: Apr 24 2008, 12:06 AM


__________________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Go to the top of the page
 
+Quote Post
   
Naridar
post Nov 4 2008, 07:58 AM
Post #4


Level 14
Group Icon

Group: Revolutionary
Posts: 250
Type: Developer
RM Skill: Skilled




Any way to "disable" the window cursor? 'Cause it just annoys me (and it's buggy). Or can anyone send me a Final Fantasy-like hand cursor?


__________________________
Go to the top of the page
 
+Quote Post
   
carbajosa
post Nov 7 2008, 11:22 PM
Post #5


Level 4
Group Icon

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




Puppeto, I think you forgot to post this:


I found that to AT Star's site along with the untranslated script ^^
That graphic file is needed in order to make a (moving) cursor in the screenie ^^
(from that, I remembered FF games lol xD Its almost the same cursor Enix was using biggrin.gif)
Gread Great job on translating it!

This post has been edited by carbajosa: Nov 10 2008, 02:09 AM
Go to the top of the page
 
+Quote Post
   
S. F. LaValle
post Feb 20 2009, 08:49 PM
Post #6


Level 1
Group Icon

Group: Member
Posts: 6
Type: None
RM Skill: Skilled




Sorry to bump, I just wanted to make a small addendum.

The existing "blink" parameter looks a little shoddy, and makes framerate inconsistencies really stand out. Here's a small code edit to make the blink much more palatable:

Comment out or remove this line (line 151):
CODE
self.visible = false if @blink and (@count % 4) == 0


And replace it with this:
CODE
self.opacity = (@count % 32) * 8 if @blink


That makes the blink effect much cleaner.

Thanks to strcat for the script and YanXie for posting!
Go to the top of the page
 
+Quote Post
   
Yo-N
post Feb 21 2009, 03:12 AM
Post #7


Level 2
Group Icon

Group: Member
Posts: 18
Type: None
RM Skill: Beginner




That's a good script you have there! laugh.gif

Congrats strcat for making a nice script!

Thanks YanXie for posting it!

Thanks to Carbajosa for posting the sursor graphic! wink.gif


__________________________

Add the Swordmaster Karel to your sig, and help him defeat the Evil Dark Druid Nergal sig floating around the forum!

^Just thought it would be fun.....^
[Show/Hide] Let's Play Red alert/Command & Conquer in space!
Go to the top of the page
 
+Quote Post
   
Nemesis
post Nov 16 2009, 10:34 AM
Post #8


Level 4
Group Icon

Group: Member
Posts: 49
Type: Event Designer
RM Skill: Skilled




The pointer wont show up in the save menu sad.gif please help with this.
Go to the top of the page
 
+Quote Post
   
Artistog2
post Sep 17 2011, 03:22 PM
Post #9



Group Icon

Group: Member
Posts: 1
Type: Event Designer
RM Skill: Intermediate




QUOTE (Nemesis @ Nov 16 2009, 10:34 AM) *
The pointer wont show up in the save menu sad.gif please help with this.




add this in a separate place under that script


[code][/code]#==========================================================================
====
# ** Window_SaveFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================

class Window_SaveFile < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :filename # filename
attr_reader :file_exist # file existence flag
attr_reader :time_stamp # timestamp
attr_reader :selected # selected
#--------------------------------------------------------------------------
# * Object Initialization
# file_index : save file index (0-3)
# filename : filename
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, 56 + file_index % 4 * 90, 544, 90)
@file_index = file_index
@filename = filename
load_gamedata
refresh
@selected = false
end
#--------------------------------------------------------------------------
# * Load Partial Game Data
# By default, switches and variables are not used (for expansion use,
# such as displaying place names)
#--------------------------------------------------------------------------
def load_gamedata
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
begin
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
@game_system = Marshal.load(file)
@game_message = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
rescue
@file_exist = false
ensure
file.close
end
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
name = Vocab::File + " #{@file_index + 1}"
self.contents.draw_text(4, 0, 200, WLH, name)
@name_width = contents.text_size(name).width
if @file_exist
draw_party_characters(152, 58)
draw_playtime(0, 34, contents.width - 4, 2)
end
end
#--------------------------------------------------------------------------
# * Draw Party Characters
# x : Draw spot X coordinate
# y : Draw spot Y coordinate
#--------------------------------------------------------------------------
def draw_party_characters(x, y)
for i in 0...@characters.size
name = @characters[i][0]
index = @characters[i][1]
draw_character(name, index, x + i * 48, y)
end
end
#--------------------------------------------------------------------------
# * Draw Play Time
# x : Draw spot X coordinate
# y : Draw spot Y coordinate
# width : Width
# align : Alignment
#--------------------------------------------------------------------------
def draw_playtime(x, y, width, align)
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width, WLH, time_string, 2)
end
#--------------------------------------------------------------------------
# * Set Selected
# selected : new selected (true = selected, false = unselected)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
if @selected
self.cursor_rect.set(0, 0, @name_width + 8, WLH)
else
self.cursor_rect.empty
end
end
end
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: 24th May 2013 - 05:11 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker