sfml3.rb

Module: SFML::Touch

Defined in:
ext/window/touch.c,
ext/window/touch.c

Overview

Real-time touch-screen state.

Class Method Summary collapse

Class Method Details

.down?(finger) ⇒ Boolean

Returns true if touch point finger is currently down.

Returns:

  • (Boolean)

Returns:

  • (Boolean) —

    whether touch point finger is currently down



35
36
37
# File 'ext/window/touch.c', line 35

static VALUE Touch_is_down(VALUE module, VALUE rb_finger) {
    return BOOL2RB(sfTouch_isDown(NUM2UINT(rb_finger)));
}

.position(finger, window = nil) ⇒ Vector2

Returns the position of touch point finger.

Returns:

Returns:

  • (Vector2) —

    the position of touch point finger, in desktop coordinates, or relative to +window+'s client area when given



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'ext/window/touch.c', line 47

static VALUE Touch_get_position(int argc, VALUE* argv, VALUE module) {
    VALUE rb_finger, rb_window;
    sfVector2i position;

    rb_scan_args(argc, argv, "11", &rb_finger, &rb_window);
    if (NIL_P(rb_window)) {
        position = sfTouch_getPosition(NUM2UINT(rb_finger), NULL);
    } else {
        position = Touch_relative_position(NUM2UINT(rb_finger), rb_window);
    }

    return vec2f_to_rb((sfVector2f){(float)position.x, (float)position.y});
}