Phaser.Rope = function (game, x, y, key, frame, points){ this.points = [] ; this.points = points; this._hasUpdateAnimation = false ; this._updateAnimationCallback = null ; x = x || 0; y = y || 0; key = key || null ; frame = frame || null ; this.type = Phaser.ROPE; PIXI.Rope.call(this, Phaser.Cache.DEFAULT, this.points); Phaser.Component.Core.init.call(this, game, x, y, key, frame); } ; Phaser.Rope.prototype = Object.create(PIXI.Rope.prototype); Phaser.Rope.prototype.constructor = Phaser.Rope; Phaser.Component.Core.install.call(Phaser.Rope.prototype, ['Angle', 'Animation', 'AutoCull', 'Bounds', 'BringToTop', 'Crop', 'Delta', 'Destroy', 'FixedToCamera', 'InWorld', 'LifeSpan', 'LoadTexture', 'Overlap', 'PhysicsBody', 'Reset', 'ScaleMinMax', 'Smoothed'] ); Phaser.Rope.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate; Phaser.Rope.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate; Phaser.Rope.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate; Phaser.Rope.prototype.preUpdateCore = Phaser.Component.Core.preUpdate; Phaser.Rope.prototype.preUpdate = function (){ if (!this.preUpdatePhysics() || !this.preUpdateLifeSpan() || !this.preUpdateInWorld()) { return false ; } return this.preUpdateCore(); } ; Phaser.Rope.prototype.update = function (){ if (this._hasUpdateAnimation) { this.updateAnimation.call(this); } } ; Phaser.Rope.prototype.reset = function (x, y){ Phaser.Component.Reset.prototype.reset.call(this, x, y); return this; } ; Object.defineProperty(Phaser.Rope.prototype, "updateAnimation", { get: function (){ return this._updateAnimation; } , set: function (value){ if (value && typeof value === 'function') { this._hasUpdateAnimation = true ; this._updateAnimation = value; } else { this._hasUpdateAnimation = false ; this._updateAnimation = null ; } } } ); Object.defineProperty(Phaser.Rope.prototype, "segments", { get: function (){ var segments = [] ; var index, x1, y1, x2, y2, width, height, rect; for (var i = 0; i < _AN_Read_length("length", this.points); i++ ){ index = i * 4; x1 = this.vertices[index] * this.scale.x; y1 = this.vertices[index + 1] * this.scale.y; x2 = this.vertices[index + 4] * this.scale.x; y2 = this.vertices[index + 3] * this.scale.y; width = Phaser.Math.difference(x1, x2); height = Phaser.Math.difference(y1, y2); x1 += this.world.x; y1 += this.world.y; rect = new Phaser.Rectangle(x1, y1, width, height); segments.push(rect); } return segments; } } );