Class: RubySketch::Sprite
- Inherits:
-
Object
- Object
- RubySketch::Sprite
- Includes:
- Xot::Inspectable
- Defined in:
- lib/rubysketch/sprite.rb
Overview
Sprite object.
Instance Method Summary collapse
-
#angle ⇒ Numeric
Returns the rotation angle of the sprite.
-
#angle=(angle) ⇒ Numeric
Sets the rotation angle of the sprite.
-
#angleFixed? ⇒ Boolean
Returns the angle of the sprite is fixed or not.
-
#bottom ⇒ Numeric
Returns the bottom position of the sprite.
-
#bottom=(n) ⇒ Numeric
Set the bottom position of the sprite.
-
#capture=(bool) ⇒ Boolean
Captures key and mouse events.
-
#capturing? ⇒ Boolean
Returns whether to capture or not.
-
#center ⇒ Vector
Returns the center position of the sprite.
-
#center=(arg) ⇒ Vector
Sets the center position of the sprite.
-
#clickCount ⇒ Numeric
Returns the mouse button click count on the sprite.
-
#contact(&block) ⇒ nil
Defines contact block.
-
#contact?(&block) ⇒ nil
Defines contact? block.
-
#contactEnd(&block) ⇒ nil
Defines contactEnd block.
-
#density ⇒ Numeric
(also: #dens)
Returns the density of the sprite.
-
#density=(n) ⇒ Numeric
(also: #dens=)
Sets the density of the sprite.
-
#draw(&block) ⇒ nil
Defines draw block.
-
#dynamic=(bool) ⇒ Boolean
Sets whether the sprite is movable by the physics engine.
-
#dynamic? ⇒ Boolean
Returns whether the sprite is movable by the physics engine.
-
#fixAngle(fix = true) ⇒ Sprite
Fixes the angle of the sprite.
-
#friction ⇒ Numeric
(also: #fric)
Returns the friction of the sprite.
-
#friction=(n) ⇒ Numeric
(also: #fric=)
Sets the friction of the sprite.
-
#fromScreen(vec) ⇒ Vector
Converts a vector from the screen coordinate.
-
#height ⇒ Numeric
(also: #h)
Returns the height of the sprite.
-
#height=(h) ⇒ Numeric
(also: #h=)
Sets the height of the sprite.
-
#hidden? ⇒ Boolean
Returns the sprite is visible.
-
#hide ⇒ Sprite
Hides the sprite.
-
#image ⇒ Image
Returns the image of the sprite.
-
#image=(img) ⇒ Image
Sets the sprite image.
-
#initialize(x = 0, y = 0, w = nil, h = nil, image: nil, offset: nil, shape: nil, physics: true, context: nil) ⇒ Sprite
constructor
Initialize sprite object.
-
#key ⇒ String
Returns the last key that was pressed or released.
-
#keyCode ⇒ Symbol
Returns the last key code that was pressed or released.
-
#keyIsDown(keyCode) ⇒ Boolean
Returns whether or not the key is currently pressed.
-
#keyIsPressed ⇒ Boolean
Returns whether or not any key is pressed.
-
#keyIsRepeated ⇒ Boolean
Returns whether the current key is repeated or not.
-
#keyPressed(&block) ⇒ Boolean
Defines keyPressed block.
-
#keyReleased(&block) ⇒ nil
Defines keyReleased block.
-
#keyTyped(&block) ⇒ nil
Defines keyTyped block.
-
#left ⇒ Numeric
Returns the left position of the sprite.
-
#left=(n) ⇒ Numeric
Set the left position of the sprite.
-
#mouseButton ⇒ LEFT, ...
Returns the mouse button clicked on the sprite.
-
#mouseClicked(&block) ⇒ nil
Defines mouseClicked block.
-
#mouseDragged(&block) ⇒ nil
Defines mouseDragged block.
-
#mouseMoved(&block) ⇒ nil
Defines mouseMoved block.
-
#mousePressed(&block) ⇒ Boolean
Defines mousePressed block.
-
#mouseReleased(&block) ⇒ nil
Defines mouseReleased block.
-
#mouseX ⇒ Numeric
Returns the x-position of the mouse in the sprite coordinates.
-
#mouseY ⇒ Numeric
Returns the y-position of the mouse in the sprite coordinates.
-
#offset ⇒ Vector
Returns the offset of the sprite image.
-
#offset=(arg) ⇒ Vector
Sets the offset of the sprite image.
-
#ox ⇒ Numeric
Returns the x-axis offset of the sprite image.
-
#ox=(x) ⇒ Numeric
Sets the x-axis offset of the sprite image.
-
#oy ⇒ Numeric
Returns the y-axis offset of the sprite image.
-
#oy=(y) ⇒ Numeric
Sets the y-axis offset of the sprite image.
-
#pivot ⇒ Array<Numeric>
Returns the rotation center of the sprite.
-
#pivot=(array) ⇒ Array<Numeric>
Sets the rotation center of the sprite.
-
#pmouseX ⇒ Numeric
Returns the previous x-position of the mouse in the sprite coordinates.
-
#pmouseY ⇒ Numeric
Returns the previous y-position of the mouse in the sprite coordinates.
-
#position ⇒ Vector
(also: #pos)
Returns the position of the sprite.
-
#position=(arg) ⇒ Vector
(also: #pos=)
Sets the position of the sprite.
-
#restitution ⇒ Numeric
(also: #rest)
Returns the restitution of the sprite.
-
#restitution=(n) ⇒ Numeric
(also: #rest=)
Sets the restitution of the sprite.
-
#right ⇒ Numeric
Returns the right position of the sprite.
-
#right=(n) ⇒ Numeric
Set the right position of the sprite.
-
#sensor=(state) ⇒ Boolean
Set this sprite as a sensor object.
-
#sensor? ⇒ Boolean
Returns whether the shape is a sensor or not.
-
#show ⇒ Sprite
Shows the sprite.
-
#size ⇒ Vector
Returns the size of the sprite.
-
#size=(arg) ⇒ Vector
Returns the size of the sprite.
-
#top ⇒ Numeric
Returns the top position of the sprite.
-
#top=(n) ⇒ Numeric
Set the top position of the sprite.
-
#toScreen(vec) ⇒ Vector
Converts a vector to the screen coordinate.
-
#touchEnded(&block) ⇒ nil
Defines touchEnded block.
-
#touches ⇒ Array<Touch>
Returns the touch objects touched on the sprite.
-
#touchMoved(&block) ⇒ nil
Defines touchMoved block.
-
#touchStarted(&block) ⇒ nil
Defines touchStarted block.
-
#update(&block) ⇒ nil
Defines update block.
-
#velocity ⇒ Vector
(also: #vel)
Returns the velocity of the sprite.
-
#velocity=(arg) ⇒ Vector
(also: #vel=)
Sets the velocity of the sprite.
-
#vx ⇒ Numeric
Returns the x-axis velocity of the sprite.
-
#vx=(n) ⇒ Numeric
Sets the x-axis velocity of the sprite.
-
#vy ⇒ Numeric
Returns the y-axis velocity of the sprite.
-
#vy=(n) ⇒ Numeric
Sets the y-axis velocity of the sprite.
-
#width ⇒ Numeric
(also: #w)
Returns the width of the sprite.
-
#width=(w) ⇒ Numeric
(also: #w=)
Sets the width of the sprite.
-
#x ⇒ Numeric
Returns the x-coordinate position of the sprite.
-
#x=(n) ⇒ Numeric
Set the x-coordinate position of the sprite.
-
#y ⇒ Numeric
Returns the y-coordinate position of the sprite.
-
#y=(n) ⇒ Numeric
Set the y-coordinate position of the sprite.
-
#z ⇒ Numeric
Returns the z-coordinate position of the sprite.
-
#z=(n) ⇒ Numeric
Set the z-coordinate position of the sprite.
Constructor Details
#new(x, y, w, h) ⇒ Sprite #new(image: img) ⇒ Sprite #new(x, y, image: img) ⇒ Sprite #new(x, y, image: img, offset: off) ⇒ Sprite #new(x, y, image: img, shape: shp) ⇒ Sprite #new(x, y, image: img, offset: off, shape: shp) ⇒ Sprite #new(x, y, shape: shp) ⇒ Sprite
Initialize sprite object.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rubysketch/sprite.rb', line 56 def initialize( x = 0, y = 0, w = nil, h = nil, image: nil, offset: nil, shape: nil, physics: true, context: nil) w ||= (image&.width || shape&.width || 0) h ||= (image&.height || shape&.height || 0) raise 'invalid size' unless w >= 0 && h >= 0 raise 'invalid image' if image && !image.getInternal__.is_a?(Rays::Image) raise 'invalid shape' if shape && !shape.getInternal__.is_a?(Reflex::Shape) @context__ = context || Context.context__ @shape__ = shape @view__ = View.new( self, x: x, y: y, w: w, h: h, shape: @shape__, physics: physics, back: :white) @view__.set density: 1, friction: 0, restitution: 0 self.image = image if image self.offset = offset if offset end |
Instance Method Details
#angle ⇒ Numeric
Returns the rotation angle of the sprite.
368 369 370 |
# File 'lib/rubysketch/sprite.rb', line 368 def angle() @context__.fromDegrees__ @view__.angle end |
#angle=(angle) ⇒ Numeric
Sets the rotation angle of the sprite.
378 379 380 381 |
# File 'lib/rubysketch/sprite.rb', line 378 def angle=(angle) @view__.angle = @context__.toDegrees__ angle angle end |
#angleFixed? ⇒ Boolean
Returns the angle of the sprite is fixed or not.
398 399 400 |
# File 'lib/rubysketch/sprite.rb', line 398 def angleFixed?() @view__.fix_angle? end |
#bottom ⇒ Numeric
Returns the bottom position of the sprite.
268 269 270 |
# File 'lib/rubysketch/sprite.rb', line 268 def bottom() @view__.bottom end |
#bottom=(n) ⇒ Numeric
Set the bottom position of the sprite.
278 279 280 |
# File 'lib/rubysketch/sprite.rb', line 278 def bottom=(n) @view__.bottom = n end |
#capture=(bool) ⇒ Boolean
Captures key and mouse events
113 114 115 116 |
# File 'lib/rubysketch/sprite.rb', line 113 def capture=(bool) @view__.capture = bool ? :all : [] bool end |
#capturing? ⇒ Boolean
Returns whether to capture or not
122 123 124 |
# File 'lib/rubysketch/sprite.rb', line 122 def capturing?() @view__.capturing? end |
#center ⇒ Vector
Returns the center position of the sprite.
286 287 288 |
# File 'lib/rubysketch/sprite.rb', line 286 def center() Vector.new(x + w / 2, y + h / 2, z) end |
#center=(vec) ⇒ Vector #center=(ary) ⇒ Vector
Sets the center position of the sprite.
300 301 302 303 304 |
# File 'lib/rubysketch/sprite.rb', line 300 def center=(arg) x, y = *(arg.is_a?(Vector) ? arg.getInternal__.to_a : arg) self.pos = [x - w / 2, y - h / 2, z] self.center end |
#clickCount ⇒ Numeric
Returns the mouse button click count on the sprite.
777 778 779 |
# File 'lib/rubysketch/sprite.rb', line 777 def clickCount() @view__.clickCount end |
#contact(&block) ⇒ nil
Defines contact block.
967 968 969 970 |
# File 'lib/rubysketch/sprite.rb', line 967 def contact(&block) @view__.contact = block if block nil end |
#contact?(&block) ⇒ nil
Defines contact? block.
995 996 997 998 |
# File 'lib/rubysketch/sprite.rb', line 995 def contact?(&block) @view__.willContact = block if block nil end |
#contactEnd(&block) ⇒ nil
Defines contactEnd block.
981 982 983 984 |
# File 'lib/rubysketch/sprite.rb', line 981 def contactEnd(&block) @view__.contactEnd = block if block nil end |
#density ⇒ Numeric Also known as: dens
Returns the density of the sprite.
594 595 596 |
# File 'lib/rubysketch/sprite.rb', line 594 def density() @view__.density end |
#density=(n) ⇒ Numeric Also known as: dens=
Sets the density of the sprite.
604 605 606 607 |
# File 'lib/rubysketch/sprite.rb', line 604 def density=(n) @view__.density = n n end |
#draw(&block) ⇒ nil
Defines draw block.
814 815 816 817 |
# File 'lib/rubysketch/sprite.rb', line 814 def draw(&block) @drawBlock__ = block if block nil end |
#dynamic=(bool) ⇒ Boolean
Sets whether the sprite is movable by the physics engine.
585 586 587 588 |
# File 'lib/rubysketch/sprite.rb', line 585 def dynamic=(bool) @view__.dynamic = bool bool end |
#dynamic? ⇒ Boolean
Returns whether the sprite is movable by the physics engine.
575 576 577 |
# File 'lib/rubysketch/sprite.rb', line 575 def dynamic?() @view__.dynamic? end |
#fixAngle(fix = true) ⇒ Sprite
Fixes the angle of the sprite.
389 390 391 392 |
# File 'lib/rubysketch/sprite.rb', line 389 def fixAngle(fix = true) @view__.fix_angle = fix self end |
#friction ⇒ Numeric Also known as: fric
Returns the friction of the sprite.
613 614 615 |
# File 'lib/rubysketch/sprite.rb', line 613 def friction() @view__.friction end |
#friction=(n) ⇒ Numeric Also known as: fric=
Sets the friction of the sprite.
623 624 625 626 |
# File 'lib/rubysketch/sprite.rb', line 623 def friction=(n) @view__.friction = n n end |
#fromScreen(vec) ⇒ Vector
Converts a vector from the screen coordinate
677 678 679 |
# File 'lib/rubysketch/sprite.rb', line 677 def fromScreen(vec) @view__.from_parent(vec.getInternal__).toVector end |
#height ⇒ Numeric Also known as: h
Returns the height of the sprite.
345 346 347 |
# File 'lib/rubysketch/sprite.rb', line 345 def height() @view__.height end |
#height=(h) ⇒ Numeric Also known as: h=
Sets the height of the sprite.
355 356 357 |
# File 'lib/rubysketch/sprite.rb', line 355 def height=(h) @view__.height = h end |
#hidden? ⇒ Boolean
Returns the sprite is visible
103 104 105 |
# File 'lib/rubysketch/sprite.rb', line 103 def hidden?() @view__.hidden? end |
#hide ⇒ Sprite
Hides the sprite
Since one call to “hide()” increases the hide count, it is necessary to call “show()” n times to make the sprite visible again after calling “hide()” n times.
94 95 96 97 |
# File 'lib/rubysketch/sprite.rb', line 94 def hide() @view__.hide self end |
#image ⇒ Image
Returns the image of the sprite.
490 491 492 |
# File 'lib/rubysketch/sprite.rb', line 490 def image() @image__ end |
#image=(img) ⇒ Image
Sets the sprite image.
500 501 502 |
# File 'lib/rubysketch/sprite.rb', line 500 def image=(img) @image__ = img end |
#key ⇒ String
Returns the last key that was pressed or released.
695 696 697 |
# File 'lib/rubysketch/sprite.rb', line 695 def key() @view__.key end |
#keyCode ⇒ Symbol
Returns the last key code that was pressed or released.
703 704 705 |
# File 'lib/rubysketch/sprite.rb', line 703 def keyCode() @view__.keyCode end |
#keyIsDown(keyCode) ⇒ Boolean
Returns whether or not the key is currently pressed.
721 722 723 |
# File 'lib/rubysketch/sprite.rb', line 721 def keyIsDown(keyCode) @view__.keysPressed.include? keyCode end |
#keyIsPressed ⇒ Boolean
Returns whether or not any key is pressed.
711 712 713 |
# File 'lib/rubysketch/sprite.rb', line 711 def keyIsPressed() not @view__.keysPressed.empty? end |
#keyIsRepeated ⇒ Boolean
Returns whether the current key is repeated or not.
729 730 731 |
# File 'lib/rubysketch/sprite.rb', line 729 def keyIsRepeated() @view__.keyRepeat end |
#keyPressed(&block) ⇒ Boolean
Defines keyPressed block.
823 824 825 826 |
# File 'lib/rubysketch/sprite.rb', line 823 def keyPressed(&block) @view__.keyPressed = block if block keyIsPressed end |
#keyReleased(&block) ⇒ nil
Defines keyReleased block.
832 833 834 835 |
# File 'lib/rubysketch/sprite.rb', line 832 def keyReleased(&block) @view__.keyReleased = block if block nil end |
#keyTyped(&block) ⇒ nil
Defines keyTyped block.
841 842 843 844 |
# File 'lib/rubysketch/sprite.rb', line 841 def keyTyped(&block) @view__.keyTyped = block if block nil end |
#left ⇒ Numeric
Returns the left position of the sprite.
213 214 215 |
# File 'lib/rubysketch/sprite.rb', line 213 def left() @view__.left end |
#left=(n) ⇒ Numeric
Set the left position of the sprite.
223 224 225 226 |
# File 'lib/rubysketch/sprite.rb', line 223 def left=(n) @view__.left = n n end |
#mouseButton ⇒ LEFT, ...
Returns the mouse button clicked on the sprite.
769 770 771 |
# File 'lib/rubysketch/sprite.rb', line 769 def mouseButton() @view__.mouseButton end |
#mouseClicked(&block) ⇒ nil
Defines mouseClicked block.
911 912 913 914 |
# File 'lib/rubysketch/sprite.rb', line 911 def mouseClicked(&block) @view__.mouseClicked = block if block nil end |
#mouseDragged(&block) ⇒ nil
Defines mouseDragged block.
897 898 899 900 |
# File 'lib/rubysketch/sprite.rb', line 897 def mouseDragged(&block) @view__.mouseDragged = block if block nil end |
#mouseMoved(&block) ⇒ nil
Defines mouseMoved block.
883 884 885 886 |
# File 'lib/rubysketch/sprite.rb', line 883 def mouseMoved(&block) @view__.mouseMoved = block if block nil end |
#mousePressed(&block) ⇒ Boolean
Defines mousePressed block.
855 856 857 858 |
# File 'lib/rubysketch/sprite.rb', line 855 def mousePressed(&block) @view__.mousePressed = block if block @view__.mousePressed? end |
#mouseReleased(&block) ⇒ nil
Defines mouseReleased block.
869 870 871 872 |
# File 'lib/rubysketch/sprite.rb', line 869 def mouseReleased(&block) @view__.mouseReleased = block if block nil end |
#mouseX ⇒ Numeric
Returns the x-position of the mouse in the sprite coordinates.
737 738 739 |
# File 'lib/rubysketch/sprite.rb', line 737 def mouseX() @view__.mouseX end |
#mouseY ⇒ Numeric
Returns the y-position of the mouse in the sprite coordinates.
745 746 747 |
# File 'lib/rubysketch/sprite.rb', line 745 def mouseY() @view__.mouseY end |
#offset ⇒ Vector
Returns the offset of the sprite image.
508 509 510 |
# File 'lib/rubysketch/sprite.rb', line 508 def offset() @offset__ end |
#offset=(vec) ⇒ Vector #offset=(ary) ⇒ Vector
Sets the offset of the sprite image.
522 523 524 525 526 527 528 529 530 531 |
# File 'lib/rubysketch/sprite.rb', line 522 def offset=(arg) @offset__ = case arg when Vector then arg when Array then Vector.new(arg[0] || 0, arg[1] || 0) when nil then nil else raise ArgumentError end offset end |
#ox ⇒ Numeric
Returns the x-axis offset of the sprite image.
537 538 539 |
# File 'lib/rubysketch/sprite.rb', line 537 def ox() @offset__&.x || 0 end |
#ox=(x) ⇒ Numeric
Sets the x-axis offset of the sprite image.
547 548 549 550 |
# File 'lib/rubysketch/sprite.rb', line 547 def ox=(x) self.offset = [x, oy] x end |
#oy ⇒ Numeric
Returns the y-axis offset of the sprite image.
556 557 558 |
# File 'lib/rubysketch/sprite.rb', line 556 def oy() @offset__&.y || 0 end |
#oy=(y) ⇒ Numeric
Sets the y-axis offset of the sprite image.
566 567 568 569 |
# File 'lib/rubysketch/sprite.rb', line 566 def oy=(y) self.offset = [ox, y] y end |
#pivot ⇒ Array<Numeric>
Returns the rotation center of the sprite.
406 407 408 |
# File 'lib/rubysketch/sprite.rb', line 406 def pivot() @view__.pivot.to_a[0, 2] end |
#pivot=(array) ⇒ Array<Numeric>
Sets the rotation center of the sprite.
- 0.0, 0.0
-
is the left-top, [1.0, 1.0] is the right-bottom, and [0.5, 0.5] is the center.
417 418 419 420 |
# File 'lib/rubysketch/sprite.rb', line 417 def pivot=(array) @view__.pivot = array pivot end |
#pmouseX ⇒ Numeric
Returns the previous x-position of the mouse in the sprite coordinates.
753 754 755 |
# File 'lib/rubysketch/sprite.rb', line 753 def pmouseX() @view__.pmouseX end |
#pmouseY ⇒ Numeric
Returns the previous y-position of the mouse in the sprite coordinates.
761 762 763 |
# File 'lib/rubysketch/sprite.rb', line 761 def pmouseY() @view__.pmouseY end |
#position ⇒ Vector Also known as: pos
Returns the position of the sprite.
130 131 132 |
# File 'lib/rubysketch/sprite.rb', line 130 def position() @view__.position.toVector end |
#position=(vec) ⇒ Vector #position=(ary) ⇒ Vector Also known as: pos=
Sets the position of the sprite.
144 145 146 147 |
# File 'lib/rubysketch/sprite.rb', line 144 def position=(arg) @view__.position = arg.is_a?(Vector) ? arg.getInternal__ : arg arg end |
#restitution ⇒ Numeric Also known as: rest
Returns the restitution of the sprite.
632 633 634 |
# File 'lib/rubysketch/sprite.rb', line 632 def restitution() @view__.restitution end |
#restitution=(n) ⇒ Numeric Also known as: rest=
Sets the restitution of the sprite.
642 643 644 645 |
# File 'lib/rubysketch/sprite.rb', line 642 def restitution=(n) @view__.restitution = n n end |
#right ⇒ Numeric
Returns the right position of the sprite.
250 251 252 |
# File 'lib/rubysketch/sprite.rb', line 250 def right() @view__.right end |
#right=(n) ⇒ Numeric
Set the right position of the sprite.
260 261 262 |
# File 'lib/rubysketch/sprite.rb', line 260 def right=(n) @view__.right = n end |
#sensor=(state) ⇒ Boolean
Set this sprite as a sensor object. Sensor object receives contact events, but no collisions.
659 660 661 |
# File 'lib/rubysketch/sprite.rb', line 659 def sensor=(state) @view__.sensor = state end |
#sensor? ⇒ Boolean
Returns whether the shape is a sensor or not.
667 668 669 |
# File 'lib/rubysketch/sprite.rb', line 667 def sensor?() @view__.sensor? end |
#show ⇒ Sprite
Shows the sprite
Since one call to “hide()” increases the hide count, it is necessary to call “show()” n times to make the sprite visible again after calling “hide()” n times.
83 84 85 86 |
# File 'lib/rubysketch/sprite.rb', line 83 def show() @view__.show self end |
#size ⇒ Vector
Returns the size of the sprite.
310 311 312 |
# File 'lib/rubysketch/sprite.rb', line 310 def size() @view__.size.toVector end |
#size=(arg) ⇒ Vector
Returns the size of the sprite.
318 319 320 321 |
# File 'lib/rubysketch/sprite.rb', line 318 def size=(arg) @view__.size = arg.is_a?(Vector) ? arg.getInternal__ : arg arg end |
#top ⇒ Numeric
Returns the top position of the sprite.
232 233 234 |
# File 'lib/rubysketch/sprite.rb', line 232 def top() @view__.top end |
#top=(n) ⇒ Numeric
Set the top position of the sprite.
242 243 244 |
# File 'lib/rubysketch/sprite.rb', line 242 def top=(n) @view__.top = n end |
#toScreen(vec) ⇒ Vector
Converts a vector to the screen coordinate
687 688 689 |
# File 'lib/rubysketch/sprite.rb', line 687 def toScreen(vec) @view__.to_parent(vec.getInternal__).toVector end |
#touchEnded(&block) ⇒ nil
Defines touchEnded block.
939 940 941 942 |
# File 'lib/rubysketch/sprite.rb', line 939 def touchEnded(&block) @view__.touchEnded = block if block nil end |
#touches ⇒ Array<Touch>
Returns the touch objects touched on the sprite.
785 786 787 |
# File 'lib/rubysketch/sprite.rb', line 785 def touches() @view__.touches end |
#touchMoved(&block) ⇒ nil
Defines touchMoved block.
953 954 955 956 |
# File 'lib/rubysketch/sprite.rb', line 953 def touchMoved(&block) @view__.touchMoved = block if block nil end |
#touchStarted(&block) ⇒ nil
Defines touchStarted block.
925 926 927 928 |
# File 'lib/rubysketch/sprite.rb', line 925 def touchStarted(&block) @view__.touchStarted = block if block nil end |
#update(&block) ⇒ nil
Defines update block.
798 799 800 801 |
# File 'lib/rubysketch/sprite.rb', line 798 def update(&block) @view__.update = block if block nil end |
#velocity ⇒ Vector Also known as: vel
Returns the velocity of the sprite.
426 427 428 |
# File 'lib/rubysketch/sprite.rb', line 426 def velocity() @view__.velocity.toVector end |
#velocity=(vec) ⇒ Vector #velocity=(ary) ⇒ Vector Also known as: vel=
Sets the velocity of the sprite.
440 441 442 443 |
# File 'lib/rubysketch/sprite.rb', line 440 def velocity=(arg) @view__.velocity = arg.is_a?(Vector) ? arg.getInternal__ : arg arg end |
#vx ⇒ Numeric
Returns the x-axis velocity of the sprite.
449 450 451 |
# File 'lib/rubysketch/sprite.rb', line 449 def vx() @view__.velocity.x end |
#vx=(n) ⇒ Numeric
Sets the x-axis velocity of the sprite.
459 460 461 462 |
# File 'lib/rubysketch/sprite.rb', line 459 def vx=(n) @view__.velocity = @view__.velocity.tap {|v| v.x = n} n end |
#vy ⇒ Numeric
Returns the y-axis velocity of the sprite.
468 469 470 |
# File 'lib/rubysketch/sprite.rb', line 468 def vy() @view__.velocity.y end |
#vy=(n) ⇒ Numeric
Sets the y-axis velocity of the sprite.
478 479 480 481 |
# File 'lib/rubysketch/sprite.rb', line 478 def vy=(n) @view__.velocity = @view__.velocity.tap {|v| v.y = n} n end |
#width ⇒ Numeric Also known as: w
Returns the width of the sprite.
327 328 329 |
# File 'lib/rubysketch/sprite.rb', line 327 def width() @view__.width end |
#width=(w) ⇒ Numeric Also known as: w=
Sets the width of the sprite.
337 338 339 |
# File 'lib/rubysketch/sprite.rb', line 337 def width=(w) @view__.width = w end |
#x ⇒ Numeric
Returns the x-coordinate position of the sprite.
153 154 155 |
# File 'lib/rubysketch/sprite.rb', line 153 def x() @view__.x end |
#x=(n) ⇒ Numeric
Set the x-coordinate position of the sprite.
163 164 165 166 |
# File 'lib/rubysketch/sprite.rb', line 163 def x=(n) @view__.x = n n end |
#y ⇒ Numeric
Returns the y-coordinate position of the sprite.
172 173 174 |
# File 'lib/rubysketch/sprite.rb', line 172 def y() @view__.y end |
#y=(n) ⇒ Numeric
Set the y-coordinate position of the sprite.
182 183 184 185 |
# File 'lib/rubysketch/sprite.rb', line 182 def y=(n) @view__.y = n n end |
#z ⇒ Numeric
Returns the z-coordinate position of the sprite.
191 192 193 |
# File 'lib/rubysketch/sprite.rb', line 191 def z() @view__.z end |
#z=(n) ⇒ Numeric
Set the z-coordinate position of the sprite.
201 202 203 204 |
# File 'lib/rubysketch/sprite.rb', line 201 def z=(n) @view__.z = n n end |