* @param {number} x - the x coordinates of the Spine object * @param {number} y - the y coordinates of the Spine object * @param {object} settings - Configuration parameters for the Spine object * @param {string} [settings.atlasFile] - the name of the atlasFile to be used to create this spine
(x, y, settings)
| 112 | * me.game.world.addChild(spineAlien); |
| 113 | */ |
| 114 | constructor(x, y, settings) { |
| 115 | super(x, y, settings.width, settings.height); |
| 116 | |
| 117 | // ensure plugin was properly registered |
| 118 | this.plugin = plugin.get(SpinePlugin); |
| 119 | if (typeof this.plugin === "undefined") { |
| 120 | throw new Error( |
| 121 | "Spine plugin: plugin needs to be registered first using plugin.register", |
| 122 | ); |
| 123 | } |
| 124 | const renderer = this.plugin.app.renderer; |
| 125 | |
| 126 | /** @ignore */ |
| 127 | this.isWebGL = renderer.WebGLVersion >= 1; |
| 128 | |
| 129 | if (this.isWebGL) { |
| 130 | this.runtime = spineWebGL; |
| 131 | // the shared canvas-backed managed context, so all spine GL |
| 132 | // resources self-restore after a WebGL context loss |
| 133 | const glContext = getManagedContext(renderer.getCanvas()); |
| 134 | // register the Spine batcher with the melonJS renderer (once) |
| 135 | if (!renderer.batchers.has("spine")) { |
| 136 | renderer.addBatcher(new SpineBatcher(renderer), "spine"); |
| 137 | } |
| 138 | this.spineBatcher = renderer.batchers.get("spine"); |
| 139 | |
| 140 | // spine skeleton renderer |
| 141 | this.skeletonRenderer = new this.runtime.SkeletonRenderer( |
| 142 | glContext, |
| 143 | true, |
| 144 | ); |
| 145 | |
| 146 | // debug renderer still uses Spine's own GL pipeline |
| 147 | this.shapesShader = this.runtime.Shader.newColored(glContext); |
| 148 | this.shapes = new this.runtime.ShapeRenderer(glContext); |
| 149 | this.skeletonDebugRenderer = new this.runtime.SkeletonDebugRenderer( |
| 150 | glContext, |
| 151 | ); |
| 152 | } else { |
| 153 | this.runtime = spineCanvas; |
| 154 | this.skeletonRenderer = new SkeletonRenderer(this.runtime); |
| 155 | } |
| 156 | |
| 157 | // force anchorPoint to 0,0 |
| 158 | this.anchorPoint.set(0, 0); |
| 159 | |
| 160 | // displaying order |
| 161 | if (typeof settings.z !== "undefined") { |
| 162 | this.pos.z = settings.z; |
| 163 | } |
| 164 | |
| 165 | // used internally when calculating bounds |
| 166 | this.boneOffset = new Vector2(); |
| 167 | this.boneSize = new Vector2(); |
| 168 | |
| 169 | // default mixTime |
| 170 | this.mixTime = settings.mixTime ?? 0.2; |
| 171 |
nothing calls this directly
no test coverage detected