Syntax
Opens a block where \property calls the catalogue command <Family><Property> on one object, so its id and the family name are written once.
WITH <FAMILY> <expression>
\<property> [<arguments>]
… \<property> …
ENDWITH
END WITHAlso written : WITH SPRITE
Parts
| <FAMILY> | A word that starts catalogue command names: SPRITE, TEXT, OBJECT, CAMERA, PARTICLES, IMAGE, MUSIC, MEMBLOCK… |
|---|---|
| <expression> | The object id passed as first argument: a variable, ships[3], a number such as 1. |
| <property> | The end of the command name: \position with SPRITE calls SpritePosition(). |
| <arguments> | The other arguments of a write, separated by commas, without parentheses. |
Good to know
- The place decides the meaning. At the head of a statement,
\propwrites:\x 50is SpriteX(s, 50). Anywhere else it reads:x# = \xis SpriteX(s). - A write has no
=.\x = 50is not refused, but the program it produces fails to start. - A write must start the statement. In
IF … THEN \visible 1, the\visibleis read as a read and the program fails to start. Use a blockIF, as in the example. - A property the catalogue does not have is a compile error: "Unknown property in WITH SPRITE: \positon".
- Lines that do not start with
\are ordinary statements. No nesting: a WITH inside a WITH is refused. - AGK names such as
SetSpritePositionorGetSpriteXdo not exist: the object comes first, the property second, withoutSetorGet.
Example
s = CreateSprite(0)WITH SPRITE s \position 100, 200 \size 64, 64 \x 50 x# = \x IF \visible = 0 \visible 1 ENDIFENDWITHConsole(Str(x#) + " " + Str(SpriteY(s))) ' 50 200In the manual : Shorthands