Sprite
Each moving entity is called a sprite. Normally sprites are defined with an image and a name. You can create a sprite
without an image then use it as a container for other things. Sprites support many parameters.
Sprites are moved using alterations. Alterations include rotation, slide and many more.
The general animation structure of SCL™ is based on this relationship.
Refer back to this brief summary/example.
After a sprite is on the screen it can be changed in a routine using update sprite
If you want to change a sprite that you just created with a clone command, then refer
to the clone by _clone instead of a sprite name.
If you want to refer to a sprite that signalled an event (such as click or completion), then
use _sprite to refer to the current sprite.
create sprite from windmill-180x180.png as windmill into windfarm
where x=100
alpha=0.5
angle=60
beenhit=OnBeenHit
center=20,25
click=clickWM
composition={see below}
enterframe=clickWM
exitframe=exitFrame
hashit=OnHasHit
hflip=true
mousein=mouseInWM
mousemove=mouseMoveWM
mouseout=mouseOutWM
parent=PlayArea
penultimate=penultimateExit
vflip=true
xscale=2.5
y=200
yscale=5.6
having target=bumbleBee
children=(fin1,fin2)
alt=spinalt=moveUp
set memvar1="dog"memvar2=4
end
- into
- sprites can be grouped and the groups used as subjects or targets of different operations (ex: collision detection).
- alpha={range 0.0-1.0}
- 0.0 makes sprite completely transparent. 1.0 makes the sprite fully opaque.
- angle={number}
- at what angle to place sprite relative to the unit circle (0 degrees is default and is pointing towards the right)
- beenhit={routine}
- specify a routine to run when it has been hit by another sprite
- center={number},{number}
- horizontal
- click={routine}
- specify a routine to run when the mouse click while on an opaque portion of the sprite. Set to _ignore to disable all user interactions on the sprite.
- composition={See below}
- This parameter determines how a sprite is drawn with
respect to the background. It can be one of: "source-atop", "source-in", "source-out", "source-over", "destination-atop", "destination-in", "destination-out", "destination-over", "lighter", "copy", "xor". It is best to experiment to see what you need or read this.
- enterframe={routine}
- specify a routine to run when when the frame is entered
- exitframe={routine}
- specify a routine to run after penultimate and after all variable conditions have been checked and all the completion routines have finished running.
- hashit={routine}
- specify a routine to run when it has hit its target (see target below)
- hflip={true|false}
- flip the sprite horizontally about the center point.
- mousein={routine}
- specify a routine to run when the mouse moves onto an opaque portion of the sprite
- mousemove={routine}
- specify a routine to run when the mouse moves within an opaque portion of the sprite
- mouseout={routine}
- specify a routine to run when the mouse moves out of an opaque portion of the sprite
- size={number}
- scale the sprite relative to its natural size.
- parent={sprite}
- specify a parent sprite onto which to attach this sprite as a child
- penultimate={routine}
- specify a routine to run after all sprites are processed for the frame, but before the var conditions are tested
- set {name}={value}
- creates a variable specific only to the sprite. Like a member variable, in OO terms.
- swipedown={routine}
- specify a routine to run when the sprite is swiped downwards via a touch screen device
- swipeup={routine}
- specify a routine to run when the sprite is swiped upwards via a touch screen device
- swipeleft={routine}
- specify a routine to run when the sprite is swiped leftwards via a touch screen device
- swiperight={routine}
- specify a routine to run when the sprite is swiped rightwards via a touch screen device
- touchdrag={routine}
- indicates that the sprite is draggable via touch on a touch screen device
- touchend={routine}
- specify a routine to run when a sprite touch is lifted off a touch screen device
- touchstart={routine}
- specify a routine to run when the sprite is first touched via a touch screen device
- vflip={true|false}
- flip the sprite vertically about the center point.
- x={number}
- horizontal position of sprite based on the sprite's center
- xscale={number}
- scale the sprite horizontally
- y={number}
- vertical position of sprite based on the sprite's center
- yscale={number}
- scale the sprite vertically
Sprite have some parameters that can have more than one value. These parameters are preceeded by a "having" clause:
- alt={alteration} and alt={alteration} and ...
- apply an alteration to the sprite. A sprite can have any number of alterations applied to it by
assigning alt repeatedly.
- children=({sprite},{sprite},...)
- specify a list of sprites that move and orient themselves relative to this
sprite. Children sprites do not need to be launched separately but are automatically launched when its parent sprite
is launched. Note, child sprites absorb events and do not relay them to the parent. Set touch events on child sprites, not the parent sprite. This will change in upcoming releases.
- target={sprite}
- specify a sprite for which to trigger a collision event
- targets={spritegroup}
- specify a group of sprites which can all trigger collision events. Sprites are assigned to groups using "into" (see above)