image (property)
Get the sprite’s current image.
let mySprite: Sprite = null
let currentImage = mySprite.image
let currentImage = mySprite.image
A sprite’s image is set when the sprite is created or a different image is set using setImage.
Returns
- the image that is the currently set for the sprite.
Example
Create a sprite with a checkbox that has a green border. Copy the checkbox image and change the border to a different color. Show a new sprite with the checkbox copy.
namespace SpriteKind {
export const Example = SpriteKind.create()
}
let sprite1 = sprites.create(img`
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7 . . . . . . . . . . . . . . 7
7 . 2 . . . . . . . . . . 2 . 7
7 . . 2 . . . . . . . . 2 . . 7
7 . . . 2 . . . . . . 2 . . . 7
7 . . . . 2 . . . . 2 . . . . 7
7 . . . . . 2 . . 2 . . . . . 7
7 . . . . . . 2 2 . . . . . . 7
7 . . . . . . 2 2 . . . . . . 7
7 . . . . . 2 . . 2 . . . . . 7
7 . . . . 2 . . . . 2 . . . . 7
7 . . . 2 . . . . . . 2 . . . 7
7 . . 2 . . . . . . . . 2 . . 7
7 . 2 . . . . . . . . . . 2 . 7
7 . . . . . . . . . . . . . . 7
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
`, SpriteKind.Example)
sprite1.y = 40
let imgInside = sprite1.image
let imgCopy = imgInside.clone()
imgCopy.drawRect(0, 0, sprite1.width, sprite1.height, 11)
let sprite2 = sprites.create(imgCopy, 0)
sprite2.y = 80