* @param {number} x - x coordinate * @param {number} y - y coordinate * @param {object} settings - ImageLayer properties * @param {HTMLImageElement|HTMLCanvasElement|CompressedImage|string} settings.image - Image reference. See loader.getImage * @param {string} [settings.name="me.Ima
(x, y, settings)
| 38 | * }), 1); |
| 39 | */ |
| 40 | constructor(x, y, settings) { |
| 41 | // call the constructor |
| 42 | super(x, y, settings); |
| 43 | |
| 44 | // render in screen coordinates |
| 45 | this.floating = true; |
| 46 | |
| 47 | // background layers should render in all cameras (e.g. minimap, split-screen) |
| 48 | this.visibleInAllCameras = true; |
| 49 | |
| 50 | // image drawing offset |
| 51 | this.offset.set(x, y); |
| 52 | |
| 53 | /** |
| 54 | * Define the image scrolling ratio<br> |
| 55 | * Scrolling speed is defined by multiplying the viewport delta position by the specified ratio. |
| 56 | * Setting this vector to <0.0,0.0> will disable automatic scrolling.<br> |
| 57 | * To specify a value through Tiled, use one of the following format : <br> |
| 58 | * - a number, to change the value for both axis <br> |
| 59 | * - a json expression like `json:{"x":0.5,"y":0.5}` if you wish to specify a different value for both x and y |
| 60 | * @type {Vector2d} |
| 61 | * @default <1.0,1.0> |
| 62 | */ |
| 63 | this.ratio = vector2dPool.get(1.0, 1.0); |
| 64 | |
| 65 | if (typeof settings.ratio !== "undefined") { |
| 66 | // little hack for backward compatibility |
| 67 | if (stringUtil.isNumeric(settings.ratio)) { |
| 68 | this.ratio.set(settings.ratio, +settings.ratio); |
| 69 | } /* vector */ else { |
| 70 | this.ratio.setV(settings.ratio); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | if (typeof settings.anchorPoint === "undefined") { |
| 75 | this.anchorPoint.set(0, 0); |
| 76 | } else { |
| 77 | if (typeof settings.anchorPoint === "number") { |
| 78 | this.anchorPoint.set(settings.anchorPoint, settings.anchorPoint); |
| 79 | } /* vector */ else { |
| 80 | this.anchorPoint.set(settings.anchorPoint.x, settings.anchorPoint.y); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | this.repeat = settings.repeat || "repeat"; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Define if and how an Image Layer should be repeated.<br> |