Lingo Dictionary > O-R > offset() (rectangle function) |  |

offset() (rectangle function)

Syntax

    rectangle.offset(horizontalChange, verticalChange)
    offset (rectangle, horizontalChange, verticalChange)

Description

Function; yields a rectangle that is offset from the rectangle specified by `rectangle`. The horizontal offset is the value specified by `horizontalChange`; the vertical offset is the value specified by `verticalChange`.

| When `horizontalChange` is greater than 0, the offset is toward the right of the Stage; when `horizontalChange` is less than 0, the offset is toward the left of the Stage.
| When `verticalChange` is greater than 0, the offset is toward the top of the Stage; when `verticalChange` is less than 0, the offset is toward the bottom of the Stage.

The values for `verticalChange` and `horizontalChange` are in pixels.

Example

This handler moves sprite 1 five pixels to the right and five pixels down.

    on diagonalMove
    	newRect=sprite(1).rect.offset(5, 5)
    	sprite(1).rect=newRect
    end