RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Scene_Base, Like Window_Base, for Scenes

0 Members and 1 Guest are viewing this topic.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
This is a resource which I hope to develope to the point it is used... A lot. (wishful thinking)

At the moment what it does is allow you to create scenes, while only having to initialize the objects in the scene and writing the seperate update methods. (for interaction)

Don't forget to make the scene a sub-class of Scene_Base, ie - (class Scene_Name < Scene_Base)

In the future I hope to include introduction animation methods and closing animation methods, as well as a variety of other methods to make writing scenes easier.

The only real difference, is that when you create an object in a scene, instead of doing -

Code: [Select]
@playtime_window = Window_PlayTime.new

You'd do -

Code: [Select]
@objects['time'] = Window_PlayTime.new

And when refering to the object, you'd obviously use -

@objects['time']

as opposed to the prior.

You can also play music in the scene, simply by adding -

Code: [Select]
super('Song Name Here')

Into the scenes initialize method.

Example -

Code: [Select]
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  # menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
@menu_index = menu_index
super('015-Theme04')
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s5 = "Save"
s6 = "End Game"
@objects['command'] = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@objects['command'].index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
  # Disable items, skills, equipment, and status
  @objects['command'].disable_item(0)
  @objects['command'].disable_item(1)
  @objects['command'].disable_item(2)
  @objects['command'].disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
  # Disable save
  @objects['command'].disable_item(4)
end
# Make play time window
@objects['time'] = Window_PlayTime.new
@objects['time'].x = 0
@objects['time'].y = 224
# Make steps window
@objects['steps'] = Window_Steps.new
@objects['steps'].x = 0
@objects['steps'].y = 320
# Make gold window
@objects['gold'] = Window_Gold.new
@objects['gold'].x = 0
@objects['gold'].y = 416
# Make status window
@objects['status'] = Window_MenuStatus.new
@objects['status'].x = 160
@objects['status'].y = 0
super
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
super
# If command window is active: call update_command
if @objects['command'].active
  update_command
  return
end
# If status window is active: call update_status
if @objects['status'].active
  update_status
  return
end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
# If B button was pressed
if Input.trigger?(Input::B)
  # Play cancel SE
  $game_system.se_play($data_system.cancel_se)
  # Switch to map screen
  $scene = Scene_Map.new
  return
end
# If C button was pressed
if Input.trigger?(Input::C)
  # If command other than save or end game, and party members = 0
  if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
  end
  # Branch by command window cursor position
  case @objects['command'].index
  when 0  # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
  when 1  # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@objects['command'].active = false
@objects['status'].active = true
@objects['status'].index = 0
  when 2  # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@objects['command'].active = false
@objects['status'].active = true
@objects['status'].index = 0
  when 3  # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@objects['command'].active = false
@objects['status'].active = true
@objects['status'].index = 0
  when 4  # save
# If saving is forbidden
if $game_system.save_disabled
  # Play buzzer SE
  $game_system.se_play($data_system.buzzer_se)
  return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
  when 5  # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
  end
  return
end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
# If B button was pressed
if Input.trigger?(Input::B)
  # Play cancel SE
  $game_system.se_play($data_system.cancel_se)
  # Make command window active
  @objects['command'].active = true
@objects['status'].active = false
@objects['status'].index = -1
  return
end
# If C button was pressed
if Input.trigger?(Input::C)
  # Branch by command window cursor position
  case @objects['command'].index
  when 1  # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@objects['status'].index].restriction >= 2
  # Play buzzer SE
  $game_system.se_play($data_system.buzzer_se)
  return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@objects['status'].index)
  when 2  # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@objects['status'].index)
  when 3  # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@objects['status'].index)
  end
  return
end
  end
end

C & C please.

Script -

Code: [Select]
class Scene_Base
def initialize(bgm = nil)
# Create Objects Hash
@objects = {}
# Store bgm value
@bgm = bgm
end
def main
# Start playing bgm unless one is not provided
$game_system.bgm_play(RPG::AudioFile.new(@bgm)) unless @bgm.nil?
# Execute transition
Graphics.transition
# Main loop
loop do
# Update Scene
update
# Abort loop if screen is changed
break if $scene != self
end
# Prepare for transition
Graphics.freeze
# Dispose of Scene
dispose
end
def update
# Update Objects unless none exist
unless @objects.empty?
  for key in @objects.keys
@objects[key].update
  end
end
# Update Graphics
Graphics.update
# Update input information
Input.update
end
def dispose
# Dispose of Objects unless none exist
unless @objects.empty?
for key in @objects.keys
@objects[key].dispose
  end
end
# Stop playing bgm unless one is not playing
$game_system.bgm_stop unless @bgm.nil?
end
end
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
*update*

Not done yet, but version 2 will include animation capabilities.

  • Intro Animation
  • Ending Animation (closing)
  • Animate at will
  • Wait a given number of frames
  • Define animation and then run it
  • Disposes of Animation once it's run, so it doesn't get played again
  • Move
  • Fade
  • Stretch

Code: [Select]
#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
# Tsunokiette
# 0.5
# October 9, 2006
#==============================================================================
class Scene_Base
#--------------------------------------------------------------------------
# * Initialization
#--------------------------------------------------------------------------
def initialize(bgm = nil)
@bgm = bgm
@intro = []
@ending = []
@animation = []
end
#--------------------------------------------------------------------------
# * Main
#--------------------------------------------------------------------------
def main
unless @bgm.nil?
file = RPG::AudioFile.new(@bgm)
$game_system.bgm_play(file)
end
Graphics.transition
@animation = @intro
animate
loop do
update
break if $scene != self
end
@animation = @ending
animate
Graphics.freeze
dispose
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update(input = true)
self.instance_variables.each.do(|item|
item.update if update_include?(item))
Graphics.update
Input.update if input
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
self.instance_variables.each.do(|item|
item.dispose if dispose_include?(item))
$game_system.bgm_stop unless @bgm.nil?
end
#--------------------------------------------------------------------------
# * List of Updatable Object Classes
#--------------------------------------------------------------------------
def updatable_objects
[Window]
end
#--------------------------------------------------------------------------
# * Returns if a given Object is listed as an Updatable Object Class
#--------------------------------------------------------------------------
def update_include?(object)
updatable_objects.each.do(|item|
return true if object.is_a?(item))
return false
end
#--------------------------------------------------------------------------
# * List of Disposable Object Classes
#--------------------------------------------------------------------------
def disposable_objects
[Window,Sprite]
end
#--------------------------------------------------------------------------
# * Returns if a given Object is listed as a Disposable Object Class
#--------------------------------------------------------------------------
def dispose_include?(object)
disposable_objects.each.do(|item|
return true if object.is_a?(item))
return false
end
#--------------------------------------------------------------------------
# * Add to Intro Animation
#--------------------------------------------------------------------------
def intro(type,window,*args)
@intro.push([type,window,*args])
end
#--------------------------------------------------------------------------
# * Add to Ending Animation
#-------------------------------------------------------------------------
def ending(type,window,*args)
@ending.push([type,window,*args])
end
#--------------------------------------------------------------------------
# * Add Move Window Command To Animation
#--------------------------------------------------------------------------
def move(window,x,y,frames)
@animation.push([0,window,x,y,frames])
end
#--------------------------------------------------------------------------
# * Add Fade Window Command To Animation
#--------------------------------------------------------------------------
def fade(window,opacity,frames)
@animation.push([1,window,opacity,frames])
end
#--------------------------------------------------------------------------
# * Add Stretch Window Command To Animation
#--------------------------------------------------------------------------
def stretch(window,w,h,frames)
@animation.push([2,window,w,h,frames])
end
#--------------------------------------------------------------------------
# * Wait a given number of frames
#--------------------------------------------------------------------------
def wait(frames)
time = Graphics.frame_count + frames
while Graphics.frame_count < time
update(false)
end
end
#--------------------------------------------------------------------------
# * Run Animation and Reset it
#-----------------------------=--------------------------------------------
def animate
return if @animation.empty?
tempa = []
@animation.each.do(|item|
if (item[0] == 0) or (item[0] == 2)
tempa.push(item)
end)
tempb = {}
tempa.each.do(|item|
if tempb[item].nil?
tempb[item] = 0
end
tempb[item] += 1)
tempc = []
tempb.each.do(|item|
tempc.push(item) if tempb[item] > 1)
@animation.each.do(|item|
if tempc.include?(item)
item[0] = 3
end)
# Code
@animation = []
end
end

Anything else you guys would like in it?
« Last Edit: October 10, 2006, 12:27:14 AM by Tsunokiette »
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
Maybe moving the window around? Like, you could make it bounce in or something.

***
Rep:
Level 88
The Sliencer
For me...No. it's great for now until the Animations are done. Well Done.

Dungeons and Dragons Dawn of Darkness: 3% (ON HOLD!)
Dark Lands: 7%

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Well, theoreticly, you could create a bounce like effect using the move command.

Oh, and a word of warning, *somewhat*, the strectch command creates an empty window with the same dimensions as the given window, and stretches itself to the given dimentions, the dimentions of the window itself won't change.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."