-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPX APIs #483
Comments
v1.3 不暴露如下概念:
另外考虑 backdrop 命名调整,详见 #456 |
Expected to expose in v1.3TODO: backdrop 相关需要调整命名
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For issue #465, #499
Current supported
spx.Sprite
SetDying
Mark sprite dying (visible but can't be touched).
SetDying()
Parent
Get the game instance.
InitFrom
Init current sprite from given sprite.
Clone
Make a clone of current sprite, with optional data (for
OnCloned
callback).OnCloned
Listen to current sprite cloned.
OnTouched
Listen to current sprite touched by another sprite, specified with optional sprite name(s).
OnMoving
Listen to current sprite moving (position change)
OnTurning
Listen to current sprite turning (direction change)
Die
Let sprite die, with animation
die
(if defined).SetDying
will be called before animation. If current sprite is cloned, it will be destroyed; If not cloned, it will be hided.Die()
Destroy
If current sprite is cloned, it will be fully deleted. Nothing happens if it is not cloned.
Destroy()
Hide
Make sprite invisible.
Hide()
Show
Make sprite visible.
Show()
Visible
Check if sprite visible.
IsCloned
Check if sprite is cloned.
CostumeName
Get current costume's name.
CostumeIndex
Get current costume's index.
SetCostume
Set current costume.
NextCostume
Use next costume as current costume.
NextCostume()
PrevCostume
Use previous costume as current costume.
PrevCostume()
Animate
Play animation with given name.
Say
Show message bubble with given message. Optional seconds can be provided.
Think
Show thinking bubble with given message. Optional seconds can be provided.
Quote
TODO
DistanceTo
Get distance to target
Move
Move given steps, toward current direction, with no animation
Step
Move given steps, toward current direction, with animation supported
Goto
Move to given target, with no animation
Glide
Move to given (x,y) position or target, with glide animation
SetXYpos
Move to given (x,y) position, with no animation
ChangeXYpos
Move with given (x,y) position change, with no animation
Xpos
Get current x position.
SetXpos
Move to given x position, with no animation
ChangeXpos
Move with given x position change, with no animation
Ypos
Get current y position.
SetYpos
Move to given y position, with no animation
ChangeYpos
Move with given y position change, with no animation
SetRotationStyle
Set rotationStyle
Heading
Get current direction.
Turn
Adjust direction, with animation
turn
(if defined)TurnTo
Turn direction to given value or target, with animation
turn
(if defined)SetHeading
Set direction to given value, with no animation
ChangeHeading
Change direction with given direction change, with no animation
Size
Get sprite size.
SetSize
Set sprite size.
ChangeSize
Change size with given size change.
SetEffect
Set graph effect of given kind with given value. Effects with different kinds may exist at the same time.
ChangeEffect
Change graph effect of given kind with given value change (based on existed value of given kind). Effects with different kinds may exist at the same time.
ClearGraphEffects
Clear all graph effects (of all kinds).
ClearGraphEffects()
TouchingColor
TODO
Touching
Check if current sprite touching specified touching target.
Note that touching target (
TouchingTarget
) is different with target, it includes:string
)Sprite
)specialObj
):Mouse
/Edge
/EdgeLeft
/EdgeTop
/EdgeRight
/EdgeBottom
BounceOffEdge
Check & bounce off if touching edge
BounceOffEdge()
GoBackLayers
Send current sprite backward by specified layer number. Negative layer number results in bringing sprite forward.
GotoFront
Bring current sprite to front.
GotoFront()
GotoBack
Send current sprite to back.
GotoBack()
Stamp
PenUp
PenDown
SetPenColor
ChangePenColor
SetPenShade
ChangePenShade
SetPenHue
ChangePenHue
SetPenHue
SetPenSize
ChangePenSize
SetPenHue
HideVar
Hide stage-monitor which targets current sprite & matches given variable name.
ShowVar
Show stage-monitor which targets current sprite & matches given variable name.
CostumeWidth
Get width of sprite current costume.
CostumeHeight
Get height of sprite current costume.
Bounds
Get bounding rectangle of current sprite.
spx.Game
IsRunned
Check if game is already running.
Run
Run the game.
MouseHitItem
MouseHitItem returns the topmost sprite which is hit by mouse.
Reload
Reload the game.
Layout
Get window size.
Update
Do game update.
Draw
EraseAll
SceneName
Get name of current scene.
SceneIndex
Get index of current scene.
StartScene
Switch to given scene. It can be blocking or non-blocking by specifying optional
wait
. Non-blocking by default.NextScene
Switch to next scene. It can be blocking or non-blocking by specifying optional
wait
. Non-blocking by default.PrevScene
Switch to previous scene. It can be blocking or non-blocking by specifying optional
wait
. Non-blocking by default.KeyPressed
Check if given key is now pressed.
MouseX
Get current x position of mouse.
MouseY
Get current y position of mouse.
MousePressed
Check if mouse is now pressed.
Username
Wait
Block current execution (coroutine) for given seconds.
Timer
ResetTimer
Ask
Answer
SetEffect
ChangeEffect
ClearSoundEffects
Play
Play given sound. By specifing extra options we can control more detailed playing behavior.
StopAllSounds
Stop all playing sounds.
StopAllSounds()
Volume
Get current volume for sounds.
SetVolume
Set current volume for sounds.
ChangeVolume
Change current volume for sounds with given volume change.
Loudness
Get current device volume for audio recording.
Broadcast
Broadcast given message with optional given data. It can be blocking or non-blocking by specifying optional
wait
. Non-blocking by default.HideVar
Hide stage-monitor which targets the stage & matches given variable name.
ShowVar
Show stage-monitor which targets the stage & matches given variable name.
spx.eventSink
OnStart
Listen to game start.
OnClick
Listen to current target (sprite / stage) clicked.
OnAnyKey
Listen to any key pressed.
OnKey
Listen to given key(s) pressed.
OnMsg
Listen to message broadcasted.
OnScene
Listen to scene switching.
Stop
Stop specified script(s)'s execution.
Global
Rand
Get random number.
Iround
Return the nearest interger to given number.
RGB
Define color with R, G, B
RGBA
Define color with R, G, B, A
Exit
Exit game.
SchedNow
Sched
SetDebug
switchAction
Action for costume / scene switch
Prev
,Next
specialDir
Heading direction / degree.
Right
,Left
,Up
,Down
specialObj
Targets for operations like
Goto
,DistanceTo
, ...Mouse
Edge
EdgeLeft
EdgeTop
EdgeRight
EdgeBottom
EffectKind
Graph effect kind for sprites.
ColorEffect
,BrightnessEffect
,GhostEffect
Key
Keys on keyboard.
Key0
-KeyAny
PlayAction
Actions for sound playing.
PlayRewind
,PlayContinue
,PlayPause
,PlayResume
,PlayStop
Pos
Special positions for operations like
Goto
.Invalid
Last
All
Random
RotationStyle
None
,Normal
,LeftRight
StopKind
All
/_All
: stop all scripts of stage/sprites and abort this scriptAllOtherScripts
: stop all other scriptsAllSprites
: stop all scripts of spritesThisSprite
: stop all scripts of this spriteThisScript
: abort this scriptOtherScriptsInSprite
: stop other scripts of this spriteExtra definitions
Target
Define
target: Target
as a target with position (sprite, mouse, ...), it may bestring
)Sprite
)specialObj
), whilespx.Mouse
onlyPos
), whilespx.Random
onlyThe text was updated successfully, but these errors were encountered: