diff options
| author | realtradam <[email protected]> | 2021-04-25 04:25:57 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-04-25 04:25:57 -0400 |
| commit | 505a4735d519253c5f173f47fbe9691bc5d9ce93 (patch) | |
| tree | a3b2600a87a4285e60165728f48a346a7b05dec3 /lib/camera/wrappers/rectangle_wrapper.rb | |
| parent | 93290fb327f4dac63ac201c4c21e13c60cae0eff (diff) | |
| download | ruby2d-camera-old-505a4735d519253c5f173f47fbe9691bc5d9ce93.tar.gz ruby2d-camera-old-505a4735d519253c5f173f47fbe9691bc5d9ce93.zip | |
.
Diffstat (limited to 'lib/camera/wrappers/rectangle_wrapper.rb')
| -rw-r--r-- | lib/camera/wrappers/rectangle_wrapper.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/camera/wrappers/rectangle_wrapper.rb b/lib/camera/wrappers/rectangle_wrapper.rb index 887ab8b..93e888a 100644 --- a/lib/camera/wrappers/rectangle_wrapper.rb +++ b/lib/camera/wrappers/rectangle_wrapper.rb @@ -4,6 +4,15 @@ module Camera # Wraps existing variables as well as adding new methods # so that it can be handled by the Camera Module module RectangleWrapped + # Rectangles are part of the exception where + # their x and y variables need to be reset + # when wrapped + def self.extended(obj) + obj.instance_exec do + @x = 0 + @y = 0 + end + end # Recalculates real coordiantes # Use after changing variables def redraw @@ -22,7 +31,7 @@ module Camera #Methods for moving the shape def x - @x ||= x1 + @x ||= 0 end def x=(x) @@ -30,7 +39,7 @@ module Camera end def y - @y ||= y1 + @y ||= 0 end def y=(y) |
