Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [XP] Inheritance
#2
You wouldn't want to inherit from a more complex class like Scene_Item, as it is designed specifically to create an item menu. But if you are using the RMXP SDK, they created a Scene_Main which is a skeleton which you can inherit from. It would fill in the blanks for things like main, update... stuff you don't need to recreate.

It is like how the window classes (Window_Selectable, Window_Help) inherit basic features from Window_Base... that way you don't have to recreate the text_color, normal_color and the like methods.

BUT... if you do perform an inherit, like 'Window_Fred < Window_Base', you can still recreate your own methods. What I mean is .... Hehe... FRED here inherits the methods from Window_Base. But if I wanted to have a different def normal_color method, I could add it in. My 'new normal_color' only shows in the Fred window while all the other windows would use the default one.

Also, there's a command called 'Alias' that you may like to learn about. It attaches code to existing methods.

Like... hrm...

Code:
class Window_PlayTime < Window_Base
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias new_refresh refresh
  def refresh
    self.contents.font.name = "Times New Roman"
    new_refresh
  end
end

This little scriptette adds a statement that changes the font for that particular window, and then runs the regular 'refresh' method. This saves you the effort of retyping the whole thing.

It'll take some practice. But hey... you're starting.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }


Messages In This Thread
[XP] Inheritance - by xuroth - 03-02-2011, 07:03 PM
RE: [XP] Inheritance - by DerVVulfman - 03-02-2011, 10:35 PM
RE: [XP] Inheritance - by xuroth - 03-03-2011, 08:33 AM
RE: [XP] Inheritance - by DerVVulfman - 03-04-2011, 05:49 AM
RE: [XP] Inheritance - by xuroth - 03-08-2011, 04:24 AM
RE: [XP] Inheritance - by DerVVulfman - 03-08-2011, 04:42 AM
RE: [XP] Inheritance - by xuroth - 03-08-2011, 05:35 AM
RE: [XP] Inheritance - by DerVVulfman - 03-08-2011, 05:45 AM
RE: [XP] Inheritance - by xuroth - 03-08-2011, 05:55 AM
RE: [XP] Inheritance - by DerVVulfman - 03-08-2011, 06:10 AM
RE: [XP] Inheritance - by xuroth - 03-08-2011, 06:30 AM
RE: [XP] Inheritance - by DerVVulfman - 03-08-2011, 06:52 AM
RE: [XP] Inheritance - by Charlie Fleed - 03-08-2011, 08:23 AM
RE: [XP] Inheritance - by xuroth - 03-08-2011, 05:19 PM
RE: [XP] Inheritance - by xuroth - 03-09-2011, 03:25 PM
RE: [XP] Inheritance - by DerVVulfman - 03-10-2011, 05:17 AM
RE: [XP] Inheritance - by xuroth - 03-11-2011, 03:21 AM
RE: [XP] Inheritance - by DerVVulfman - 03-11-2011, 04:41 AM
RE: [XP] Inheritance - by Victor Sant - 03-12-2011, 09:36 PM
RE: [XP] Inheritance - by DerVVulfman - 03-13-2011, 04:24 AM



Users browsing this thread: