Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SDK question, about Scene_Base

Could someone explain the Scene_Base part of the SDK?
It starts on about line 2012 in 2.4
The main question I have is why it forces all instance variables of a scene to update. (Line 2099 for checking each variable, and 2145 where it actually updates)
This is... problematic when the Scene's update method also updates individual objects, causing some things, like a Window, to update twice per tick, and causing strange behavior.
 
BwdYeti":13fv17mk said:
Could someone explain the Scene_Base part of the SDK?
It starts on about line 2012 in 2.4
The main question I have is why it forces all instance variables of a scene to update. (Line 2099 for checking each variable, and 2145 where it actually updates)
This is... problematic when the Scene's update method also updates individual objects, causing some things, like a Window, to update twice per tick, and causing strange behavior.
Just remove any object.update from your custom scenes.

EDIT: You asked why it forces, but this is the main idea behind the Scene_Base. Compare the default way of writing a scene and the scene-base way:
Code:
class Scene_Custom
  def main
    obj1 = Obj1.new
    obj2 = Obj2.new
    ...
    objn =Objn.new
    while $scene == self
      obj1.update
      obj2.update
      ...
      objn.update
      Input.update
      Graphics.update
    end
    obj1.dispose
    obj2.dispose
    ...
    objn.dispose
  end
end
What a mess!!!! Now look at the scene-base way:
Code:
class Scene_Custom < SDK::Scene_Base
  def main_init
    super
    obj1 = Obj1.new
    obj2 = Obj2.new
    ...
    objn =Objn.new
  end
end
Wow! It will update and dispose all my objects, and I don't have to worry about that.
 
You can disable the auto-update of your classes by returning false in "disable_update?" method. SDK::Scene_Base will not update an object if this method returns true.
Code:
class MyClass
  def disable_dispose?
    true
  end
end
 
Oh, that's useful. Thanks. It's nice the SDK people had foresight on including things like that.
EDIT: Searching for that in the SDK, individual objects can have that added to them? That's even more useful since I'm editing Scene_Map, and don't want all the old stuff to not update, just what I'm adding. Very nice.
 
BwdYeti":1bqkxb1z said:
EDIT: Searching for that in the SDK, individual objects can have that added to them? That's even more useful since I'm editing Scene_Map, and don't want all the old stuff to not update, just what I'm adding. Very nice.
That's how it's supposed to work.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top