-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstringToAsset.ts
47 lines (42 loc) · 1.33 KB
/
stringToAsset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace images{
/**
* Returns an image from a string
*/
//% blockId=getImageFromString
//% block="get image from $asset_name"
//% group="Assets from Strings"
//% weight=1
export function getImage(asset_name: string): Image{
return helpers._getFactoryInstance("image", asset_name)
}
/**
* Returns a tile from a string
*/
//% blockId=getTileFromString
//% block="get tile from $asset_name"
//% group="Assets from Strings"
//% weight=1
export function getTile(asset_name: string): Image {
return helpers._getFactoryInstance("tile", asset_name)
}
/**
* Returns a tilemap from a string
*/
//% blockId=getTilemapFromString
//% block="get tilemap from $asset_name"
//% group="Assets from Strings"
//% weight=1
export function getTilemap(asset_name: string): tiles.TileMapData {
return helpers._getFactoryInstance("tilemap", asset_name)
}
/**
* Returns an animation from a string
*/
//% blockId=getAnimationFromString
//% block="get animation from $asset_name"
//% group="Assets from Strings"
//% weight=1
export function getAnimation(asset_name: string): Image[] {
return helpers._getFactoryInstance("animation", asset_name)
}
}