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.

Ignoring Tone

khmp

Sponsor

In the hidden sprite class is a method for manipulating tone. I need to alias the manipulation of this property if possible.

Code:
class Sprite
  attr_accessor :ignore_tone
  alias_method :test_sprite_tone=, :tone=
  def tone=(tone)
    p 'here'
    return if ignore_tone
    self.test_sprite_tone=(tone)
  end
end

It never reaches that print. So I assume I'm screwing up somewhere or aliasing the wrong method. I would be eternally grateful to someone who might be able to offer a solution or guidance to this dilemma.

Thanks for taking the time to read this. :thumb:
 

khmp

Sponsor

You're absolutely right. I omitted an important detail I guess. The problem lies in the fact that I'm doing this through a Viewport object. In XP the above code works as well. :lol: Here's what I'm trying to get done. When the Viewport's tone is changed I want some of the sprites within the viewport to be ignored. I figured the Viewport was setting each of the Sprite's tones when the Viewport's tone was changed. Looks like I'm wrong.

Code:
viewport = Viewport.new(0, 0, 640, 480)
sprite1 = Sprite.new(viewport)
sprite2 = Sprite.new(viewport)
viewport.tone = Tone.new(0, 0, 0, 0)
 
...normally hidden classes can only only be acces like so:
class << Input
class << Graphics

blabla... im not sure if that will help... although most hidden "classes" are actually modules (input and graphics are)
 

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