new Sprite(source, pos, width, height, angleopt, yAdjustmentopt, animationGapopt, p5Instopt)
init a sprite
Parameters:
Name |
Type |
Attributes |
Default |
Description |
source |
p5.Image
|
|
|
source image for the sprite, single image is load and use for animation and rotation (if any), see readme for more info |
pos |
Vector
|
|
|
{x, y} or a p5.Vector object |
width |
number
|
|
|
|
height |
number
|
|
|
|
angle |
number
|
<optional>
|
0
|
|
yAdjustment |
number
|
<optional>
|
0
|
[-0.5, 0.5] -0.5 ~ 0.5, negative number will make the sprite appear lower and positive number will make it appear higher |
animationGap |
number
|
<optional>
|
0
|
number of frame for before change to the next animation |
p5Inst |
p5
|
<optional>
|
null
|
reference to the p5 instance if in instance mode, if not specified try to call functions blind to windows |
- Source:
Methods
destroy()
destroy the sprite to free resources
- Source:
drawBuffer()
update image buffer of the sprite
- Source:
move(movement)
Parameters:
Name |
Type |
Description |
movement |
Vector
|
{x, y} or a p5.Vector |
- Source:
rotate(angle)
Parameters:
Name |
Type |
Description |
angle |
number
|
|
- Source:
rotateTo(angle)
Parameters:
Name |
Type |
Description |
angle |
number
|
|
- Source:
scale(xRatio, yRatio)
Parameters:
Name |
Type |
Description |
xRatio |
number
|
|
yRatio |
number
|
|
- Source:
scaleTo(xRatio, yRatio)
scale to the ratio relative to the origin size
Parameters:
Name |
Type |
Description |
xRatio |
number
|
|
yRatio |
number
|
|
- Source:
setAnimationGap(gap)
Parameters:
Name |
Type |
Description |
gap |
number
|
number of frame (main canvas) for before change to the other animation |
- Source:
setAnimationGroups(grouping)
advance animation control
Parameters:
Name |
Type |
Description |
grouping |
Array
|
arrays of animation frames in group, e.g. [[0,1,2,3],[4,5,6]] |
- Source:
setCurrentAnimationGroup(group)
Parameters:
Name |
Type |
Description |
group |
number
|
|
- Source:
setYAdjustment(ratio)
Parameters:
Name |
Type |
Description |
ratio |
number
|
0.5 ~ 0.5, negative number will make the sprite appear lower and positive number will make it appear higher |
- Source:
update(frameCount)
update the animation, should have animation rate set
Parameters:
Name |
Type |
Description |
frameCount |
number
|
current frame count from main canvas |
- Source:
updateAnimationFrame(newFrame)
update the new frame for the animation
Parameters:
Name |
Type |
Description |
newFrame |
number
|
|
- Source:
updateRotationFrame(angle)
Parameters:
Name |
Type |
Description |
angle |
number
|
|
- Source: