Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Calintz on October 13, 2009, 02:46:49 pm

Title: What's Wrong??
Post by: Calintz on October 13, 2009, 02:46:49 pm
What's wrong with this??
The text, and the bitmap don't show ...
Spoiler: ShowHide
#===============================================================================
# Calintz's CMS v1.0
# Enhanced Menu System
#===============================================================================

class CalintzCMS < Window_Base

#===============================================================================
# Object Initialize
#===============================================================================
 def initialize
   super(0, 0, 640, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
 end
 
 def refresh
   self.contents.clear
   self.contents.font.color = normal_color
   self.contents.font.size = 20
   cx = contents.text_size("Hello").width
   self.font.draw_text(width/3, height/3+100, cx, 32, "Hello")
   @bitmap = RPG::Cache.battler("Luke", 0)
   self.contents.blt(width/3, height/3, @bitmap, Rect.new(0, 0, @bitmap.width,
   @bitmap.height), 160)
 end
 
end

#===============================================================================
# Calintz's CMS Scene
#===============================================================================

class Scene_CalintzCMS
 
#===============================================================================
# Main Processing
#===============================================================================
 def main
   # call the window
   @window = CalintzCMS.new
   # execute transition
   Graphics.transition
   # main loop
   loop do
     # update game screen
     Graphics.update
     # update input information
     Input.update
     # frame update
     update
     # abort this loop if the screen changes
     if $scene != self
       break
     end
   end
   # prepare for transition
   Graphics.transition
   # dispose of the window
   @window.dispose
 end
 #-----------------------------------------------------------------------------
 # Frame Update
 #-----------------------------------------------------------------------------
 def update
   # update windows
   @window.update
   # if the B button is pressed ...
   if Input.trigger?(Input::B)
     # play cancel se
     $game_system.se_play($data_system.cancel_se)
     # return to menu
     $scene = Scene_Menu.new
     return
   end
   
 end
 
end
Title: Re: What's Wrong??
Post by: G_G on October 13, 2009, 03:57:55 pm
Here you forgot to call the refresh method
#===============================================================================
# Calintz's CMS v1.0
# Enhanced Menu System
#===============================================================================

class CalintzCMS < Window_Base

#===============================================================================
# Object Initialize
#===============================================================================
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    # NEW CODE BELOW
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    cx = contents.text_size("Hello").width
    self.font.draw_text(width/3, height/3+100, cx, 32, "Hello")
    @bitmap = RPG::Cache.battler("Luke", 0)
    self.contents.blt(width/3, height/3, @bitmap, Rect.new(0, 0, @bitmap.width,
    @bitmap.height), 160)
  end
 
end

#===============================================================================
# Calintz's CMS Scene
#===============================================================================

class Scene_CalintzCMS
 
#===============================================================================
# Main Processing
#===============================================================================
  def main
    # call the window
    @window = CalintzCMS.new
    # execute transition
    Graphics.transition
    # main loop
    loop do
      # update game screen
      Graphics.update
      # update input information
      Input.update
      # frame update
      update
      # abort this loop if the screen changes
      if $scene != self
        break
      end
    end
    # prepare for transition
    Graphics.transition
    # dispose of the window
    @window.dispose
  end
  #-----------------------------------------------------------------------------
  # Frame Update
  #-----------------------------------------------------------------------------
  def update
    # update windows
    @window.update
    # if the B button is pressed ...
    if Input.trigger?(Input::B)
      # play cancel se
      $game_system.se_play($data_system.cancel_se)
      # return to menu
      $scene = Scene_Menu.new
      return
    end
   
  end
 
end
Title: Re: What's Wrong??
Post by: winkio on October 13, 2009, 04:17:20 pm
also:

self.font.draw_text(width/3, height/3+100, cx, 32, "Hello")

needs to be changed to

self.contents.draw_text(width/3, height/3+100, cx, 32, "Hello")
Title: Re: What's Wrong??
Post by: Calintz on October 13, 2009, 04:26:26 pm
Wow, thank you ...
It's amazing what even one key will do to a script.