Creating GameObject of variable size using Chingu

119 Views Asked by At

I'm trying to make a GameObject which does not use Gosu::Image but Chingu::Rect. That's my class by omitting all unimportant methods

class Tile < Chingu::GameObject
  trait :bounding_box
  trait :collision_detection

  def initialize (x, y, w, h, opts={})
    super opts
    @area = Chingu::Rect.new(x,y,w,h)
  end

  def collision_at?(x, y)
    @area.collide_point?(x,y)
  end       
end

However collision detection is not working. Does anybody know how to tell the bounding_box to use a specific Rectangle and not an Image?

0

There are 0 best solutions below