Syntax
Attaches a command family to a variable, so that s.position(100, 200) calls SpritePosition(s, 100, 200) and s.x reads SpriteX(s), anywhere in the program.
<var> = Create<Family>(…)
<var> AS <Family>
<var>.<property>(<arguments>)
<var>.<property> = <value>
… <var>.<property> …Also written : s.position(x, y)
Parts
| <var> | A variable that holds an object id. |
|---|---|
| <Family> | The command family: deduced from Create<Family>(, Load<Family>( or Clone<Family>( when it is the whole right side, or declared with AS Sprite, AS Object, AS Camera… |
| <property> | The end of a catalogue command name of that family: position, x, visible… |
| <arguments> | The other arguments of the command. Reads inside them are rewritten too. |
| <value> | The value to write. It is copied as written, not rewritten. |
Good to know
- The
=write does not rewrite its right side. Ins.angle = s.angle + 5, the rights.anglestays as written and the sprite receives something that is not a number, with no error. Use the call form:s.angle(s.angle + 5). - The
=write must be a whole statement. AfterTHENon a one-lineIF, use the call form:IF s.visible = 0 THEN s.visible(1). - CreateObjectBox(), CreatePointLight() and other creation names that carry more than the family give no family: declare
box AS Objectfirst. CreateObjectSphere() gives a wrong family that wins overAS Object: use its form that takes an id. - A family is not a parameter type:
FUNCTION Move(s AS Sprite)is refused ("Unknown BASIC parameter type"). Take the parameter untyped and writes AS Spriteon the first line of the body. - An unknown property is a compile error: "Unknown property on sprite: .positon". Only properties:
s.delete()is refused, write DeleteSprite(s). - Left alone: variables with no family, record fields (
hero.health), list or map members,SELF.fieldin a method, and the inside of strings.
Example
img = LoadImage("hero.png")s = CreateSprite(img)s.position(100, 200)s.visible = 1s.x(s.x + 10)Console(Str(s.x) + " " + Str(s.visible)) ' 110 1In the manual : Shorthands