* Update function (automatically called by melonJS). * @param {number} dt - time since the last update in milliseconds. * @returns {boolean} true if the renderable is dirty
(dt)
| 369 | * @returns {boolean} true if the renderable is dirty |
| 370 | */ |
| 371 | update(dt) { |
| 372 | if (typeof this.skeleton !== "undefined") { |
| 373 | const deltaSeconds = dt / 1000; |
| 374 | |
| 375 | // advance skeleton time for physics simulation |
| 376 | this.skeleton.update(deltaSeconds); |
| 377 | |
| 378 | // update and apply the animation state |
| 379 | this.animationState.update(deltaSeconds); |
| 380 | this.animationState.apply(this.skeleton); |
| 381 | |
| 382 | // position the skeleton (added directly to root worldX/worldY, |
| 383 | // bypassing Skeleton.yDir scaling that would flip a rootBone.pose.y) |
| 384 | this.skeleton.x = this.pos.x; |
| 385 | this.skeleton.y = this.pos.y; |
| 386 | |
| 387 | // world transforms |
| 388 | this.skeleton.updateWorldTransform(Physics.update); |
| 389 | |
| 390 | // update Bounds |
| 391 | this.updateBounds(); |
| 392 | } |
| 393 | return true; |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Draw this Spine object using the appropriate renderer. |