Skip to content
Browse files

Merge branch 'v1.2.3' into v1.3.0

Library rebuilt.
  • Loading branch information...
2 parents b7710ab + 5d96ca8 commit 78db0c3146d90505e32935ee0337c8a5c7fa6f78 @BenjaminDRichards BenjaminDRichards committed
Showing with 705 additions and 522 deletions.
  1. +14 −1 README.md
  2. +154 −115 build/kiwi.d.ts
  3. +156 −116 build/kiwi.js
  4. +4 −4 build/kiwi.min.js
  5. BIN docs/assets/favicon.png
  6. +39 −33 gruntfile.js
  7. +5 −2 src/components/ArcadePhysics.ts
  8. +2 −0 src/core/Entity.ts
  9. +45 −33 src/geom/Intersect.ts
  10. +130 −102 src/time/Clock.ts
  11. +156 −116 templateGame/lib/kiwi.js
View
15 README.md
@@ -7,7 +7,7 @@ Kiwi.js is the world's easiest to use Open Source HTML5 game framework for makin
Our focus is blazingly fast WebGL rendering and complementary tools to make professional quality serious games. We use [CocoonJS](https://www.ludei.com/) for publishing games and App creation.
-Version: 1.2.2 "Williams"
+Version: 1.2.3 "Williams"
- Visit the [Official Website](http://www.kiwijs.org/documentation/getting-started/)
- Follow us on [Twitter](http://www.twitter.com/kiwijsengine)
@@ -37,6 +37,19 @@ Our [Official Documentation Codex](http://www.kiwijs.org/documentation/getting-s
Number tags refer to [GitHub issues](https://github.com/gamelab/kiwi.js/issues).
+### v1.2.3 "Williams"
+
+### Bug Fixes
+
+* `Clock.elapsed()` now resets to 0 after `start()` is called. (#177)
+* `Geom.Intersect.lineToLineSegment` and `lineSegmentToLineSegment` now work correctly. (#172)
+
+### Deprecations
+
+* `Entity.inputEnabled` wasn't used by anything, and is now officially deprecated.
+
+More details can be found on the [Kiwi.JS repo](https://github.com/gamelab/kiwi.js) under the [1.2.3 milestone](https://github.com/gamelab/kiwi.js/issues?q=milestone%3Av1.2.3)
+
### v1.2.2 "Williams"
### Bug Fixes
View
269 build/kiwi.d.ts
@@ -2065,6 +2065,7 @@ declare module Kiwi {
* @property _inputEnabled
* @type boolean
* @private
+ * @deprecated As of 1.2.3, nothing was found to use this.
*/
private _inputEnabled;
/**
@@ -2073,6 +2074,7 @@ declare module Kiwi {
* @property inputEnabled
* @type boolean
* @public
+ * @deprecated As of 1.2.3, nothing was found to use this.
*/
inputEnabled: boolean;
/**
@@ -6137,10 +6139,13 @@ declare module Kiwi.Components {
*/
parent: Kiwi.Entity;
/**
- * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component.
+ * Sets the parent's rotation to be equal to the trajectory of the
+ * velocity of the physics component. Note that rotation 0 corresponds
+ * to pointing directly to the right.
* @method rotateToVelocity
- * @return { Number }
+ * @return {number} New rotation value
* @public
+ * @since 1.3.0
*/
rotateToVelocity(): number;
/**
@@ -14986,14 +14991,20 @@ declare module Kiwi.Geom {
static lineToLine(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
/**
* Check to see if a Line and a Line Segment intersect at any point.
- * Note: The first line passed is treated as if it extends infinately though space,
- * The second is treated as if it only exists between its two points.
+ * Note: The first line passed is treated as if it extends infinitely
+ * though space. The second is treated as if it only exists between
+ * its two points.
*
* @method lineToLineSegment
- * @param line1 {Kiwi.Geom.Line} The first line to check. This is the one that will extend through space infinately.
- * @param seg {Kiwi.Geom.Line} The second line to check. This is the one that will only exist between its two coordinates.
- * @param [output] {Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection.
+ * @param line1 {Kiwi.Geom.Line} The first line to check.
+ This is the one that will extend through space infinately.
+ * @param seg {Kiwi.Geom.Line} The second line to check.
+ This is the one that will only exist between its two coordinates.
+ * @param [output] {Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in. One is
+ created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection.
* @public
* @static
*/
@@ -15071,19 +15082,23 @@ declare module Kiwi.Geom {
*/
static lineToRectangle(line: any, rect: Rectangle, output?: IntersectResult): IntersectResult;
/**
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
* Line Segment
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
**/
/**
* Checks to see if two Line Segments intersect at any point in space.
- * Note: Both lines are treated as if they only exist between their two line coordinates.
+ * Note: Both lines are treated as if they only exist between their two
+ * line coordinates.
*
* @method lineSegmentToLineSegment
* @param line1 {Kiwi.Geom.Line} The first line object to check.
* @param line2 {Kiwi.Geom.Line} The second line object to check.
- * @param [output]{Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection in x/y.
+ * @param [output]{Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in.
+ One is created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection in x/y.
* @public
* @static
*/
@@ -19405,48 +19420,60 @@ declare module Kiwi.Sound {
}
}
/**
-*
* @module Kiwi
* @submodule Time
-*
*/
declare module Kiwi.Time {
/**
- * The Clock class offers a way of tracking time within a game. When creating a new Clock you should NOT directly instantiate this class but instead use the addClock method on a ClockManager.
- * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks real world time in milliseconds elapsed since the application started. This happens automatically and there is no need to do anything to set this up.
- * - An instance of a clock is used to track time in arbitrary units (milliseconds by default)
- * - A clock can be started, paused, unpaused and stopped. Once stopped, re-starting the clock again will reset it. It can also have its time scale freely transformed.
- * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer class for timer details.
- * - If the clock is paused, any timers attached to the clock will take this into account and not continue to fire events until the clock is unpaused. (Note that this is not the same as pausing timers, which can be done manually and needs to be undone manually.)
+ * The Clock class offers a way of tracking time within a game.
+ * When creating a new Clock you should NOT directly instantiate this class
+ * but instead use the addClock method on a ClockManager.
+ * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks
+ * real world time in milliseconds elapsed since the application started.
+ * This happens automatically and there is no need to do anything to set
+ * this up.
+ * - An instance of a clock is used to track time in arbitrary units
+ * (milliseconds by default)
+ * - A clock can be started, paused, unpaused and stopped. Once stopped,
+ * re-starting the clock again will reset it. It can also have its time
+ * scale freely transformed.
+ * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer
+ * class for timer details.
+ * - If the clock is paused, any timers attached to the clock will take this
+ * into account and not continue to fire events until the clock is
+ * unpaused. (Note that this is not the same as pausing timers, which can
+ * be done manually and needs to be undone manually.)
* - Animations and TweenManagers can use any Clock.
*
* @class Clock
* @namespace Kiwi.Time
* @constructor
- * @param manager {ClockManager} The ClockManager that this clock belongs to.
- * @param master {Kiwi.Time.MasterClock} The MasterClock that it is getting the time in relation to.
- * @param name {String} The name of the clock.
- * @param [units=1000] {Number} The units that this clock is to operate in per second.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param manager {ClockManager} ClockManager that this clock belongs to
+ * @param master {Kiwi.Time.MasterClock} MasterClock that this is getting
+ * the time in relation to
+ * @param name {String} Name of the clock
+ * @param [units=1000] {Number} Units that this clock is to operate in
+ * per second
+ * @return {Kiwi.Time.Clock} This Clock object
*/
class Clock {
constructor(manager: Kiwi.Time.ClockManager, master: Kiwi.Time.MasterClock, name: string, units?: number);
/**
- * The type of object that this is.
+ * The type of object that this is
* @method objType
* @return {String} "Clock"
* @public
*/
objType(): string;
/**
- * A collection of Timer objects using this clock.
+ * Collection of Timer objects using this clock
* @property timers
* @type Timer[]
* @private
*/
private timers;
/**
- * The time the clock was first started relative to the master clock.
+ * Time the clock was first started relative to the master clock
* @property _timeFirstStarted
* @type Number
* @default null
@@ -19454,14 +19481,14 @@ declare module Kiwi.Time {
*/
private _timeFirstStarted;
/**
- * The number of clock units elapsed since the clock was first started.
- * @method elapsedSinceFirstStarted.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was first started
+ * @method elapsedSinceFirstStarted
+ * @return {Number} Number of clock units elapsed
* @public
*/
elapsedSinceFirstStarted(): number;
/**
- * The time the clock was most recently started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @property _timeLastStarted
* @type Number
* @default null
@@ -19469,15 +19496,15 @@ declare module Kiwi.Time {
*/
private _timeLastStarted;
/**
- * Get the most recent time the clock was started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @method started
- * @return {Number} milliseconds.
+ * @return {Number} Milliseconds
* @public
*/
started(): number;
/**
* Rate at which time passes on this clock.
- * 1 is normal speed. 0 is no speed. -1 is backwards.
+ * 1 is normal speed. 1.5 is faster. 0 is no speed. -1 is backwards.
* This mostly affects timers, animations and tweens.
* @property timeScale
* @type number
@@ -19545,14 +19572,16 @@ declare module Kiwi.Time {
*/
maxFrameDuration: number;
/**
- * The number of clock units elapsed since the clock was most recently started (not including time spent paused)
+ * Number of clock units elapsed since the clock was most recently
+ * started (not including time spent paused)
* @method elapsed
- * @return {Number} number of clock units.
+ * @return {Number} Number of clock units
* @public
*/
elapsed(): number;
/**
- * The time the clock was most recently stopped relative to the master clock.
+ * Time the clock was most recently stopped relative to the
+ * master clock.
* @property _timeLastStopped
* @type Number
* @default null
@@ -19560,14 +19589,16 @@ declare module Kiwi.Time {
*/
private _timeLastStopped;
/**
- * The number of clock units elapsed since the clock was most recently stopped.
- * @method elapsedSinceLastStopped.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * stopped.
+ * @method elapsedSinceLastStopped
+ * @return {Number} Number of clock units
* @public
*/
elapsedSinceLastStopped(): number;
/**
- * The time the clock was most receently paused relative to the master clock.
+ * Time the clock was most receently paused relative to the
+ * master clock.
* @property _timeLastPaused
* @private
* @type Number
@@ -19576,14 +19607,15 @@ declare module Kiwi.Time {
*/
private _timeLastPaused;
/**
- * The number of clock units elapsed since the clock was most recently paused.
- * @method elapsedSinceLastPaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently paused.
+ * @method elapsedSinceLastPaused
+ * @return {Number} Number of clock units
* @public
*/
elapsedSinceLastPaused(): number;
/**
- * The time the clock was most recently unpaused relative to the master clock.
+ * Time the clock was most recently unpaused relative to the
+ * master clock.
* @property _timeLastUnpaused
* @private
* @type Number
@@ -19592,14 +19624,16 @@ declare module Kiwi.Time {
*/
private _timeLastUnpaused;
/**
- * The number of clock units elapsed since the clock was most recently unpaused.
- * @method elapsedSinceLastUnpaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * unpaused.
+ * @method elapsedSinceLastUnpaused
+ * @return {Number} Number of clock units
* @public
*/
elapsedSinceLastUnpaused(): number;
/**
- * The total number of milliseconds the clock has been paused since it was last started.
+ * Total number of milliseconds the clock has been paused
+ * since it was last started
* @property _totalPaused
* @private
* @type Number
@@ -19608,7 +19642,7 @@ declare module Kiwi.Time {
*/
private _totalPaused;
/**
- * Whether the clock is in a running state.
+ * Whether the clock is in a running state
* @property _isRunning
* @type boolean
* @default false
@@ -19616,14 +19650,14 @@ declare module Kiwi.Time {
*/
private _isRunning;
/**
- * Check if the clock is currently running.
+ * Check if the clock is currently running
* @method isRunning
- * @return {boolean} true if running.
+ * @return {boolean} `true` if running
* @public
*/
isRunning(): boolean;
/**
- * Whether the clock is in a stopped state.
+ * Whether the clock is in a stopped state
* @property _isStopped
* @type boolean
* @default true
@@ -19631,14 +19665,14 @@ declare module Kiwi.Time {
*/
private _isStopped;
/**
- * Check if the clock is in the stopped state.
+ * Check if the clock is in the stopped state
* @method isStopped
- * @return {boolean} true if stopped.
+ * @return {boolean} `true` if stopped
* @public
*/
isStopped(): boolean;
/**
- * Whether the clock is in a paused state.
+ * Whether the clock is in a paused state
* @property _isPaused
* @type boolean
* @default false
@@ -19646,28 +19680,28 @@ declare module Kiwi.Time {
*/
private _isPaused;
/**
- * Check if the clock is in the paused state.
+ * Check if the clock is in the paused state
* @method isPaused
- * @return {boolean} true if paused.
+ * @return {boolean} `true` if paused
* @public
*/
isPaused(): boolean;
/**
- * An internal reference to the state of the elapsed timer
+ * Internal reference to the state of the elapsed timer
* @property _elapsedState
* @type Number
* @private
*/
private _elapsedState;
/**
- * The time manager that this clock belongs to.
+ * Time manager that this clock belongs to
* @property manager
* @type ClockManager
* @public
*/
manager: Kiwi.Time.ClockManager;
/**
- * The master clock.
+ * Master clock from which time is derived
* @property master
* @type Kiwi.Time.MasterClock
* @public
@@ -19681,7 +19715,7 @@ declare module Kiwi.Time {
*/
name: string;
/**
- * The number of milliseconds counted as one unit of time by the clock.
+ * Number of milliseconds counted as one unit of time by the clock
* @property units
* @type Number
* @default 0
@@ -19729,56 +19763,60 @@ declare module Kiwi.Time {
/**
* Add an existing Timer to the Clock.
* @method addTimer
- * @param timer {Timer} Timer object instance to be added to this Clock.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param timer {Timer} Timer object instance to be added to this Clock
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
addTimer(timer: Timer): Clock;
/**
- * Creates a new Timer and adds it to this Clock.
+ * Create a new Timer and add it to this Clock.
* @method createTimer
- * @param name {string} The name of the Timer (must be unique on this Clock).
- * @param [delay=1] {Number} The number of clock units to wait between firing events (default 1)
- * @param [repeatCount=0] {Number} The number of times to repeat this Timer (default 0)
- * @param [start=true] {Boolean} If the timer should start.
- * @return {Kiwi.Time.Timer} The newly created Timer.
+ * @param name {string} Name of the Timer (must be unique on this Clock)
+ * @param [delay=1] {Number} Number of clock units to wait between
+ * firing events
+ * @param [repeatCount=0] {Number} Number of times to repeat the Timer
+ * (default 0)
+ * @param [start=true] {Boolean} If the timer should start
+ * @return {Kiwi.Time.Timer} The newly created Timer
* @public
*/
createTimer(name: string, delay?: number, repeatCount?: number, start?: boolean): Timer;
/**
- * Remove a Timer from this Clock based on either the Timer object or its name.
+ * Remove a Timer from this Clock based on either the Timer object
+ * or its name.
* @method removeTimer
- * @param [timer=null] {Timer} The Timer object you wish to remove. If you wish to delete by Timer Name set this to null.
- * @param [timerName=''] {string} The name of the Timer object to remove.
- * @return {boolean} True if the Timer was successfully removed, false if not.
+ * @param [timer=null] {Timer} Timer object you wish to remove.
+ * If you wish to delete by Timer Name set this to null.
+ * @param [timerName=''] {string} Name of the Timer object to remove
+ * @return {boolean} `true` if the Timer was successfully removed
* @public
*/
removeTimer(timer?: Timer, timerName?: string): boolean;
/**
- * Check if the Timer already exists on this Clock
+ * Check if the Timer already exists on this Clock.
* @method checkExists
- * @param name {string} The name of the Timer.
- * @return {boolean} true if the Timer exists, false if not.
+ * @param name {string} Name of the Timer
+ * @return {boolean} `true` if the Timer exists
* @public
*/
checkExists(name: string): boolean;
/**
* Stop all timers attached to the clock.
* @method stopAllTimers
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
stopAllTimers(): Clock;
/**
* Convert a number to milliseconds based on clock units.
- * @method toMilliseconds.
- * @param time {number} seconds
- * @return {Number} milliseconds.
+ * @method toMilliseconds
+ * @param time {number} Seconds
+ * @return {Number} Milliseconds
* @public
*/
convertToMilliseconds(time: number): number;
/**
- * Updates all Timers linked to this Clock.
+ * Update all Timers linked to this Clock.
* @method update
* @public
*/
@@ -19786,79 +19824,80 @@ declare module Kiwi.Time {
/**
* Start the clock. This resets the clock and starts it running.
* @method start
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
start(): Clock;
/**
- * Pause the clock. The clock can only be paused if it is already running.
+ * Pause the clock. This can only be paused if it is already running.
* @method pause
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
pause(): Clock;
/**
- * Resume the clock. The clock can only be resumed if it is already paused.
+ * Resume the clock. This can only be resumed if it is already paused.
* @method resume
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
resume(): Clock;
/**
- * Stop the clock. Clock can only be stopped if it is already running or is paused.
+ * Stop the clock. This can only be stopped if it is already running
+ * or is paused.
* @method stop
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
stop(): Clock;
/**
- * Returns a string representation of this object.
+ * Return a string representation of this object.
* @method toString
- * @return {string} a string representation of the instance.
+ * @return {string} String representation of the instance
* @public
*/
toString(): string;
/**
* Set a function to execute after a certain time interval.
- * Emulates window.setTimeout, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setTimeout`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearTimeout is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearTimeout` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setTimeout
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds before execution
- * @param [context] {object} Object to be "this" for the callback
- * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used to further
- * manipulate the timer
+ * @param [context] {object} Object to be `this` for the callback
+ * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used
+ * to further manipulate the timer
* @public
*/
setTimeout(callback: any, timeout: number, context: any, ...args: any[]): Timer;
/**
* Set a function to repeatedly execute at fixed time intervals.
- * Emulates window.setInterval, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setInterval`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearInterval is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearInterval` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setInterval
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds between executions
- * @param [context=window] {object} Object to be "this" for the callback
+ * @param [context=window] {object} Object to be `this` for the callback
* @return {Kiwi.Time.Timer} Kiwi.Time.Timer object
* which can be used to further manipulate the timer
* @public
View
272 build/kiwi.js
@@ -2811,6 +2811,7 @@ var Kiwi;
* @property inputEnabled
* @type boolean
* @public
+ * @deprecated As of 1.2.3, nothing was found to use this.
*/
set: function (value) {
this._inputEnabled = value;
@@ -8659,10 +8660,13 @@ var Kiwi;
this._callbackContext = callbackContext;
};
/**
- * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component.
+ * Sets the parent's rotation to be equal to the trajectory of the
+ * velocity of the physics component. Note that rotation 0 corresponds
+ * to pointing directly to the right.
* @method rotateToVelocity
- * @return { Number }
+ * @return {number} New rotation value
* @public
+ * @since 1.3.0
*/
ArcadePhysics.prototype.rotateToVelocity = function () {
var result = Math.atan2(this.velocity.y, this.velocity.x);
@@ -21317,14 +21321,20 @@ var Kiwi;
};
/**
* Check to see if a Line and a Line Segment intersect at any point.
- * Note: The first line passed is treated as if it extends infinately though space,
- * The second is treated as if it only exists between its two points.
+ * Note: The first line passed is treated as if it extends infinitely
+ * though space. The second is treated as if it only exists between
+ * its two points.
*
* @method lineToLineSegment
- * @param line1 {Kiwi.Geom.Line} The first line to check. This is the one that will extend through space infinately.
- * @param seg {Kiwi.Geom.Line} The second line to check. This is the one that will only exist between its two coordinates.
- * @param [output] {Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection.
+ * @param line1 {Kiwi.Geom.Line} The first line to check.
+ This is the one that will extend through space infinately.
+ * @param seg {Kiwi.Geom.Line} The second line to check.
+ This is the one that will only exist between its two coordinates.
+ * @param [output] {Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in. One is
+ created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection.
* @public
* @static
*/
@@ -21339,8 +21349,7 @@ var Kiwi;
var minX = Math.min(seg.x1, seg.x2);
var maxY = Math.max(seg.y1, seg.y2);
var minY = Math.min(seg.y1, seg.y2);
- //if (!(output.x <= maxX && output.x >= minX) || !(output.y <= maxY && output.y >= minY))
- if ((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true) {
+ if ((output.x <= maxX && output.x >= minX) === true && (output.y <= maxY && output.y >= minY) === true) {
output.result = true;
}
}
@@ -21495,19 +21504,23 @@ var Kiwi;
return output;
};
/**
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
* Line Segment
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
**/
/**
* Checks to see if two Line Segments intersect at any point in space.
- * Note: Both lines are treated as if they only exist between their two line coordinates.
+ * Note: Both lines are treated as if they only exist between their two
+ * line coordinates.
*
* @method lineSegmentToLineSegment
* @param line1 {Kiwi.Geom.Line} The first line object to check.
* @param line2 {Kiwi.Geom.Line} The second line object to check.
- * @param [output]{Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection in x/y.
+ * @param [output]{Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in.
+ One is created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection in x/y.
* @public
* @static
*/
@@ -27894,38 +27907,50 @@ var Kiwi;
})(Sound = Kiwi.Sound || (Kiwi.Sound = {}));
})(Kiwi || (Kiwi = {}));
/**
-*
* @module Kiwi
* @submodule Time
-*
*/
var Kiwi;
(function (Kiwi) {
var Time;
(function (Time) {
/**
- * The Clock class offers a way of tracking time within a game. When creating a new Clock you should NOT directly instantiate this class but instead use the addClock method on a ClockManager.
- * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks real world time in milliseconds elapsed since the application started. This happens automatically and there is no need to do anything to set this up.
- * - An instance of a clock is used to track time in arbitrary units (milliseconds by default)
- * - A clock can be started, paused, unpaused and stopped. Once stopped, re-starting the clock again will reset it. It can also have its time scale freely transformed.
- * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer class for timer details.
- * - If the clock is paused, any timers attached to the clock will take this into account and not continue to fire events until the clock is unpaused. (Note that this is not the same as pausing timers, which can be done manually and needs to be undone manually.)
+ * The Clock class offers a way of tracking time within a game.
+ * When creating a new Clock you should NOT directly instantiate this class
+ * but instead use the addClock method on a ClockManager.
+ * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks
+ * real world time in milliseconds elapsed since the application started.
+ * This happens automatically and there is no need to do anything to set
+ * this up.
+ * - An instance of a clock is used to track time in arbitrary units
+ * (milliseconds by default)
+ * - A clock can be started, paused, unpaused and stopped. Once stopped,
+ * re-starting the clock again will reset it. It can also have its time
+ * scale freely transformed.
+ * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer
+ * class for timer details.
+ * - If the clock is paused, any timers attached to the clock will take this
+ * into account and not continue to fire events until the clock is
+ * unpaused. (Note that this is not the same as pausing timers, which can
+ * be done manually and needs to be undone manually.)
* - Animations and TweenManagers can use any Clock.
*
* @class Clock
* @namespace Kiwi.Time
* @constructor
- * @param manager {ClockManager} The ClockManager that this clock belongs to.
- * @param master {Kiwi.Time.MasterClock} The MasterClock that it is getting the time in relation to.
- * @param name {String} The name of the clock.
- * @param [units=1000] {Number} The units that this clock is to operate in per second.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param manager {ClockManager} ClockManager that this clock belongs to
+ * @param master {Kiwi.Time.MasterClock} MasterClock that this is getting
+ * the time in relation to
+ * @param name {String} Name of the clock
+ * @param [units=1000] {Number} Units that this clock is to operate in
+ * per second
+ * @return {Kiwi.Time.Clock} This Clock object
*/
var Clock = (function () {
function Clock(manager, master, name, units) {
if (units === void 0) { units = 1000; }
/**
- * The time the clock was first started relative to the master clock.
+ * Time the clock was first started relative to the master clock
* @property _timeFirstStarted
* @type Number
* @default null
@@ -27933,7 +27958,7 @@ var Kiwi;
*/
this._timeFirstStarted = null;
/**
- * The time the clock was most recently started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @property _timeLastStarted
* @type Number
* @default null
@@ -27942,7 +27967,7 @@ var Kiwi;
this._timeLastStarted = null;
/**
* Rate at which time passes on this clock.
- * 1 is normal speed. 0 is no speed. -1 is backwards.
+ * 1 is normal speed. 1.5 is faster. 0 is no speed. -1 is backwards.
* This mostly affects timers, animations and tweens.
* @property timeScale
* @type number
@@ -27983,7 +28008,8 @@ var Kiwi;
*/
this._maxFrameDuration = -1;
/**
- * The time the clock was most recently stopped relative to the master clock.
+ * Time the clock was most recently stopped relative to the
+ * master clock.
* @property _timeLastStopped
* @type Number
* @default null
@@ -27991,7 +28017,8 @@ var Kiwi;
*/
this._timeLastStopped = null;
/**
- * The time the clock was most receently paused relative to the master clock.
+ * Time the clock was most receently paused relative to the
+ * master clock.
* @property _timeLastPaused
* @private
* @type Number
@@ -28000,7 +28027,8 @@ var Kiwi;
*/
this._timeLastPaused = null;
/**
- * The time the clock was most recently unpaused relative to the master clock.
+ * Time the clock was most recently unpaused relative to the
+ * master clock.
* @property _timeLastUnpaused
* @private
* @type Number
@@ -28009,7 +28037,8 @@ var Kiwi;
*/
this._timeLastUnpaused = null;
/**
- * The total number of milliseconds the clock has been paused since it was last started.
+ * Total number of milliseconds the clock has been paused
+ * since it was last started
* @property _totalPaused
* @private
* @type Number
@@ -28018,7 +28047,7 @@ var Kiwi;
*/
this._totalPaused = 0;
/**
- * Whether the clock is in a running state.
+ * Whether the clock is in a running state
* @property _isRunning
* @type boolean
* @default false
@@ -28026,7 +28055,7 @@ var Kiwi;
*/
this._isRunning = false;
/**
- * Whether the clock is in a stopped state.
+ * Whether the clock is in a stopped state
* @property _isStopped
* @type boolean
* @default true
@@ -28034,7 +28063,7 @@ var Kiwi;
*/
this._isStopped = true;
/**
- * Whether the clock is in a paused state.
+ * Whether the clock is in a paused state
* @property _isPaused
* @type boolean
* @default false
@@ -28042,21 +28071,21 @@ var Kiwi;
*/
this._isPaused = false;
/**
- * An internal reference to the state of the elapsed timer
+ * Internal reference to the state of the elapsed timer
* @property _elapsedState
* @type Number
* @private
*/
this._elapsedState = Kiwi.Time.Clock._RUNNING;
/**
- * The time manager that this clock belongs to.
+ * Time manager that this clock belongs to
* @property manager
* @type ClockManager
* @public
*/
this.manager = null;
/**
- * The master clock.
+ * Master clock from which time is derived
* @property master
* @type Kiwi.Time.MasterClock
* @public
@@ -28070,7 +28099,7 @@ var Kiwi;
*/
this.name = null;
/**
- * The number of milliseconds counted as one unit of time by the clock.
+ * Number of milliseconds counted as one unit of time by the clock
* @property units
* @type Number
* @default 0
@@ -28089,7 +28118,7 @@ var Kiwi;
this._currentMasterElapsed = this.master.elapsed();
}
/**
- * The type of object that this is.
+ * The type of object that this is
* @method objType
* @return {String} "Clock"
* @public
@@ -28098,18 +28127,18 @@ var Kiwi;
return "Clock";
};
/**
- * The number of clock units elapsed since the clock was first started.
- * @method elapsedSinceFirstStarted.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was first started
+ * @method elapsedSinceFirstStarted
+ * @return {Number} Number of clock units elapsed
* @public
*/
Clock.prototype.elapsedSinceFirstStarted = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeFirstStarted) / this.units : null;
};
/**
- * Get the most recent time the clock was started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @method started
- * @return {Number} milliseconds.
+ * @return {Number} Milliseconds
* @public
*/
Clock.prototype.started = function () {
@@ -28136,63 +28165,66 @@ var Kiwi;
configurable: true
});
/**
- * The number of clock units elapsed since the clock was most recently started (not including time spent paused)
+ * Number of clock units elapsed since the clock was most recently
+ * started (not including time spent paused)
* @method elapsed
- * @return {Number} number of clock units.
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsed = function () {
return this._elapsed;
};
/**
- * The number of clock units elapsed since the clock was most recently stopped.
- * @method elapsedSinceLastStopped.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * stopped.
+ * @method elapsedSinceLastStopped
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsedSinceLastStopped = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeLastStopped) / this.units : null;
};
/**
- * The number of clock units elapsed since the clock was most recently paused.
- * @method elapsedSinceLastPaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently paused.
+ * @method elapsedSinceLastPaused
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsedSinceLastPaused = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeLastPaused) / this.units : null;
};
/**
- * The number of clock units elapsed since the clock was most recently unpaused.
- * @method elapsedSinceLastUnpaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * unpaused.
+ * @method elapsedSinceLastUnpaused
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsedSinceLastUnpaused = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeLastUnpaused) / this.units : null;
};
/**
- * Check if the clock is currently running.
+ * Check if the clock is currently running
* @method isRunning
- * @return {boolean} true if running.
+ * @return {boolean} `true` if running
* @public
*/
Clock.prototype.isRunning = function () {
return this._isRunning;
};
/**
- * Check if the clock is in the stopped state.
+ * Check if the clock is in the stopped state
* @method isStopped
- * @return {boolean} true if stopped.
+ * @return {boolean} `true` if stopped
* @public
*/
Clock.prototype.isStopped = function () {
return this._isStopped;
};
/**
- * Check if the clock is in the paused state.
+ * Check if the clock is in the paused state
* @method isPaused
- * @return {boolean} true if paused.
+ * @return {boolean} `true` if paused
* @public
*/
Clock.prototype.isPaused = function () {
@@ -28201,8 +28233,8 @@ var Kiwi;
/**
* Add an existing Timer to the Clock.
* @method addTimer
- * @param timer {Timer} Timer object instance to be added to this Clock.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param timer {Timer} Timer object instance to be added to this Clock
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.addTimer = function (timer) {
@@ -28210,13 +28242,15 @@ var Kiwi;
return this;
};
/**
- * Creates a new Timer and adds it to this Clock.
+ * Create a new Timer and add it to this Clock.
* @method createTimer
- * @param name {string} The name of the Timer (must be unique on this Clock).
- * @param [delay=1] {Number} The number of clock units to wait between firing events (default 1)
- * @param [repeatCount=0] {Number} The number of times to repeat this Timer (default 0)
- * @param [start=true] {Boolean} If the timer should start.
- * @return {Kiwi.Time.Timer} The newly created Timer.
+ * @param name {string} Name of the Timer (must be unique on this Clock)
+ * @param [delay=1] {Number} Number of clock units to wait between
+ * firing events
+ * @param [repeatCount=0] {Number} Number of times to repeat the Timer
+ * (default 0)
+ * @param [start=true] {Boolean} If the timer should start
+ * @return {Kiwi.Time.Timer} The newly created Timer
* @public
*/
Clock.prototype.createTimer = function (name, delay, repeatCount, start) {
@@ -28230,11 +28264,13 @@ var Kiwi;
return this.timers[this.timers.length - 1];
};
/**
- * Remove a Timer from this Clock based on either the Timer object or its name.
+ * Remove a Timer from this Clock based on either the Timer object
+ * or its name.
* @method removeTimer
- * @param [timer=null] {Timer} The Timer object you wish to remove. If you wish to delete by Timer Name set this to null.
- * @param [timerName=''] {string} The name of the Timer object to remove.
- * @return {boolean} True if the Timer was successfully removed, false if not.
+ * @param [timer=null] {Timer} Timer object you wish to remove.
+ * If you wish to delete by Timer Name set this to null.
+ * @param [timerName=''] {string} Name of the Timer object to remove
+ * @return {boolean} `true` if the Timer was successfully removed
* @public
*/
Clock.prototype.removeTimer = function (timer, timerName) {
@@ -28260,10 +28296,10 @@ var Kiwi;
return false;
};
/**
- * Check if the Timer already exists on this Clock
+ * Check if the Timer already exists on this Clock.
* @method checkExists
- * @param name {string} The name of the Timer.
- * @return {boolean} true if the Timer exists, false if not.
+ * @param name {string} Name of the Timer
+ * @return {boolean} `true` if the Timer exists
* @public
*/
Clock.prototype.checkExists = function (name) {
@@ -28277,7 +28313,7 @@ var Kiwi;
/**
* Stop all timers attached to the clock.
* @method stopAllTimers
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
Clock.prototype.stopAllTimers = function () {
@@ -28288,16 +28324,16 @@ var Kiwi;
};
/**
* Convert a number to milliseconds based on clock units.
- * @method toMilliseconds.
- * @param time {number} seconds
- * @return {Number} milliseconds.
+ * @method toMilliseconds
+ * @param time {number} Seconds
+ * @return {Number} Milliseconds
* @public
*/
Clock.prototype.convertToMilliseconds = function (time) {
return time * this.units;
};
/**
- * Updates all Timers linked to this Clock.
+ * Update all Timers linked to this Clock.
* @method update
* @public
*/
@@ -28330,7 +28366,7 @@ var Kiwi;
/**
* Start the clock. This resets the clock and starts it running.
* @method start
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
Clock.prototype.start = function () {
@@ -28343,12 +28379,15 @@ var Kiwi;
this._isPaused = false;
this._isStopped = false;
this._elapsedState = Kiwi.Time.Clock._RUNNING;
+ this._elapsed = 0;
+ this._lastMasterElapsed = this.master.elapsed();
+ this._currentMasterElapsed = this.master.elapsed();
return this;
};
/**
- * Pause the clock. The clock can only be paused if it is already running.
+ * Pause the clock. This can only be paused if it is already running.
* @method pause
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.pause = function () {
@@ -28362,9 +28401,9 @@ var Kiwi;
return this;
};
/**
- * Resume the clock. The clock can only be resumed if it is already paused.
+ * Resume the clock. This can only be resumed if it is already paused.
* @method resume
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.resume = function () {
@@ -28379,9 +28418,10 @@ var Kiwi;
return this;
};
/**
- * Stop the clock. Clock can only be stopped if it is already running or is paused.
+ * Stop the clock. This can only be stopped if it is already running
+ * or is paused.
* @method stop
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.stop = function () {
@@ -28398,9 +28438,9 @@ var Kiwi;
return this;
};
/**
- * Returns a string representation of this object.
+ * Return a string representation of this object.
* @method toString
- * @return {string} a string representation of the instance.
+ * @return {string} String representation of the instance
* @public
*/
Clock.prototype.toString = function () {
@@ -28408,24 +28448,24 @@ var Kiwi;
};
/**
* Set a function to execute after a certain time interval.
- * Emulates window.setTimeout, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setTimeout`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearTimeout is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearTimeout` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setTimeout
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds before execution
- * @param [context] {object} Object to be "this" for the callback
- * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used to further
- * manipulate the timer
+ * @param [context] {object} Object to be `this` for the callback
+ * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used
+ * to further manipulate the timer
* @public
*/
Clock.prototype.setTimeout = function (callback, timeout, context) {
@@ -28446,22 +28486,22 @@ var Kiwi;
};
/**
* Set a function to repeatedly execute at fixed time intervals.
- * Emulates window.setInterval, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setInterval`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearInterval is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearInterval` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setInterval
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds between executions
- * @param [context=window] {object} Object to be "this" for the callback
+ * @param [context=window] {object} Object to be `this` for the callback
* @return {Kiwi.Time.Timer} Kiwi.Time.Timer object
* which can be used to further manipulate the timer
* @public
View
8 build/kiwi.min.js
4 additions, 4 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN docs/assets/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
72 gruntfile.js
@@ -1,22 +1,22 @@
module.exports = function(grunt) {
- require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
+ require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
// Project configuration.
grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
+ pkg: grunt.file.readJSON("package.json"),
- BASE_PATH: '',
- DEVELOPMENT_PATH: '',
+ BASE_PATH: "",
+ DEVELOPMENT_PATH: "",
ts: {
build: {
src: ["./src/**/*.ts"],
- out: './build/kiwi.js',
+ out: "./build/kiwi.js",
options: {
- target: 'es5',
- module: 'commonjs',
+ target: "es5",
+ module: "commonjs",
sourcemap: false,
declaration: true,
comments: true
@@ -26,15 +26,15 @@ module.exports = function(grunt) {
yuidoc: {
compile: {
- name: '<%= pkg.name %>',
- description: '<%= pkg.description %>',
- version: '<%= pkg.version %>',
- url: '<%= pkg.homepage %>',
+ name: "<%= pkg.name %>",
+ description: "<%= pkg.description %>",
+ version: "<%= pkg.version %>",
+ url: "<%= pkg.homepage %>",
options: {
- extension: '.ts',
- paths: '<%= DEVELOPMENT_PATH %>' + 'src/',
- outdir: '<%= BASE_PATH %>' + 'docs/'
+ extension: ".ts",
+ paths: "<%= DEVELOPMENT_PATH %>" + "src/",
+ outdir: "<%= BASE_PATH %>" + "docs/"
}
}
},
@@ -42,19 +42,19 @@ module.exports = function(grunt) {
uglify: {
build: {
files: {
- 'build/kiwi.min.js': ['build/kiwi.js']
+ "build/kiwi.min.js": ["build/kiwi.js"]
}
}
},
concat: {
build: {
- src: ['build/kiwi.js', 'src/gl-matrix-min.js'],
- dest: 'build/kiwi.js'
+ src: ["build/kiwi.js", "src/gl-matrix-min.js"],
+ dest: "build/kiwi.js"
},
buildmin: {
- src: ['build/kiwi.min.js', 'src/gl-matrix-min.js'],
- dest: 'build/kiwi.min.js'
+ src: ["build/kiwi.min.js", "src/gl-matrix-min.js"],
+ dest: "build/kiwi.min.js"
}
},
@@ -69,30 +69,36 @@ module.exports = function(grunt) {
copy: {
doclogo: {
- src: 'docstyles/logo.png',
- dest: 'docs/assets/css/logo.png'
+ src: "docstyles/logo.png",
+ dest: "docs/assets/css/logo.png"
},
docfavicon: {
- src: 'docstyles/favicon.png',
- dest: 'docs/assets/favicon.png'
+ src: "docstyles/favicon.png",
+ dest: "docs/assets/favicon.png"
},
docstyles: {
- src: 'docstyles/main.css',
- dest: 'docs/assets/css/main.css'
+ src: "docstyles/main.css",
+ dest: "docs/assets/css/main.css"
},
templateGame: {
- src: './build/kiwi.js',
- dest: './templateGame/lib/kiwi.js'
+ src: "./build/kiwi.js",
+ dest: "./templateGame/lib/kiwi.js"
}
}
});
- grunt.registerTask("default", ["ts:build", "tslint", "concat:build", "uglify:build", "copy:templateGame"]);
- grunt.registerTask("full", ["ts:build", "concat:build", "uglify:build", "yuidoc:compile", "copy:templateGame", "copy:doclogo", "copy:docstyles"]);
- grunt.registerTask("docs", ["yuidoc:compile", "copy:doclogo", "copy:docstyles", "copy:docfavicon"]);
- grunt.registerTask("join", ["concat:build"]);
-
-};
+ grunt.registerTask( "default", [
+ "ts:build", "tslint", "concat:build", "uglify:build",
+ "copy:templateGame" ] );
+ grunt.registerTask( "full", [
+ "ts:build", "tslint", "concat:build", "uglify:build",
+ "yuidoc:compile", "copy:templateGame",
+ "copy:doclogo", "copy:docstyles", "copy:docfavicon" ] );
+ grunt.registerTask( "docs", [
+ "yuidoc:compile", "copy:doclogo",
+ "copy:docstyles", "copy:docfavicon" ] );
+ grunt.registerTask( "join", [ "concat:build" ] );
+};
View
7 src/components/ArcadePhysics.ts
@@ -327,10 +327,13 @@ module Kiwi.Components {
public parent: Kiwi.Entity;
/**
- * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component.
+ * Sets the parent's rotation to be equal to the trajectory of the
+ * velocity of the physics component. Note that rotation 0 corresponds
+ * to pointing directly to the right.
* @method rotateToVelocity
- * @return { Number }
+ * @return {number} New rotation value
* @public
+ * @since 1.3.0
*/
public rotateToVelocity (): number {
View
2 src/core/Entity.ts
@@ -570,6 +570,7 @@ module Kiwi {
* @property _inputEnabled
* @type boolean
* @private
+ * @deprecated As of 1.2.3, nothing was found to use this.
*/
private _inputEnabled: boolean;
@@ -579,6 +580,7 @@ module Kiwi {
* @property inputEnabled
* @type boolean
* @public
+ * @deprecated As of 1.2.3, nothing was found to use this.
*/
public set inputEnabled(value: boolean) {
this._inputEnabled = value;
View
78 src/geom/Intersect.ts
@@ -113,43 +113,51 @@ module Kiwi.Geom {
/**
* Check to see if a Line and a Line Segment intersect at any point.
- * Note: The first line passed is treated as if it extends infinately though space,
- * The second is treated as if it only exists between its two points.
+ * Note: The first line passed is treated as if it extends infinitely
+ * though space. The second is treated as if it only exists between
+ * its two points.
*
* @method lineToLineSegment
- * @param line1 {Kiwi.Geom.Line} The first line to check. This is the one that will extend through space infinately.
- * @param seg {Kiwi.Geom.Line} The second line to check. This is the one that will only exist between its two coordinates.
- * @param [output] {Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection.
+ * @param line1 {Kiwi.Geom.Line} The first line to check.
+ This is the one that will extend through space infinately.
+ * @param seg {Kiwi.Geom.Line} The second line to check.
+ This is the one that will only exist between its two coordinates.
+ * @param [output] {Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in. One is
+ created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection.
* @public
* @static
*/
- static lineToLineSegment(line1: Line, seg: Line, output: IntersectResult = new IntersectResult): IntersectResult {
+ static lineToLineSegment( line1: Line, seg: Line, output: IntersectResult = new IntersectResult ): IntersectResult {
output.result = false;
- var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 - seg.x2);
-
- if (denom !== 0)
- {
- output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom;
- output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom;
-
- var maxX = Math.max(seg.x1, seg.x2);
- var minX = Math.min(seg.x1, seg.x2);
- var maxY = Math.max(seg.y1, seg.y2);
- var minY = Math.min(seg.y1, seg.y2);
+ var denom = ( line1.x1 - line1.x2 ) * ( seg.y1 - seg.y2 ) -
+ ( line1.y1 - line1.y2 ) * ( seg.x1 - seg.x2 );
- //if (!(output.x <= maxX && output.x >= minX) || !(output.y <= maxY && output.y >= minY))
- if ((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true)
- {
+ if ( denom !== 0 ) {
+ output.x = ( ( line1.x1 * line1.y2 - line1.y1 * line1.x2 ) *
+ ( seg.x1 - seg.x2 ) - ( line1.x1 - line1.x2 ) *
+ ( seg.x1 * seg.y2 - seg.y1 * seg.x2 ) ) / denom;
+ output.y = ( ( line1.x1 * line1.y2 - line1.y1 * line1.x2 ) *
+ ( seg.y1 - seg.y2 ) - (line1.y1 - line1.y2 ) *
+ ( seg.x1 * seg.y2 - seg.y1 * seg.x2 ) ) / denom;
+
+ var maxX = Math.max( seg.x1, seg.x2 );
+ var minX = Math.min( seg.x1, seg.x2 );
+ var maxY = Math.max( seg.y1, seg.y2 );
+ var minY = Math.min( seg.y1, seg.y2 );
+
+ if ( ( output.x <= maxX && output.x >= minX ) === true &&
+ ( output.y <= maxY && output.y >= minY ) === true ) {
output.result = true;
}
}
return output;
-
}
/**
@@ -344,20 +352,24 @@ module Kiwi.Geom {
}
/**
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
* Line Segment
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
**/
/**
* Checks to see if two Line Segments intersect at any point in space.
- * Note: Both lines are treated as if they only exist between their two line coordinates.
+ * Note: Both lines are treated as if they only exist between their two
+ * line coordinates.
*
* @method lineSegmentToLineSegment
* @param line1 {Kiwi.Geom.Line} The first line object to check.
* @param line2 {Kiwi.Geom.Line} The second line object to check.
- * @param [output]{Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection in x/y.
+ * @param [output]{Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in.
+ One is created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection in x/y.
* @public
* @static
*/
@@ -365,13 +377,13 @@ module Kiwi.Geom {
output.result = false;
- Intersect.lineToLineSegment(line1, line2, output);
+ Intersect.lineToLineSegment( line1, line2, output );
- if (output.result === true)
- {
- if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2)
- && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2)))
- {
+ if ( output.result === true ) {
+ if ( !( output.x >= Math.min( line1.x1, line1.x2 ) &&
+ output.x <= Math.max( line1.x1, line1.x2 ) &&
+ output.y >= Math.min( line1.y1, line1.y2 ) &&
+ output.y <= Math.max( line1.y1, line1.y2 ) ) ) {
output.result = false;
}
}
View
232 src/time/Clock.ts
@@ -1,29 +1,41 @@
/**
-*
* @module Kiwi
* @submodule Time
-*
*/
module Kiwi.Time {
/**
- * The Clock class offers a way of tracking time within a game. When creating a new Clock you should NOT directly instantiate this class but instead use the addClock method on a ClockManager.
- * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks real world time in milliseconds elapsed since the application started. This happens automatically and there is no need to do anything to set this up.
- * - An instance of a clock is used to track time in arbitrary units (milliseconds by default)
- * - A clock can be started, paused, unpaused and stopped. Once stopped, re-starting the clock again will reset it. It can also have its time scale freely transformed.
- * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer class for timer details.
- * - If the clock is paused, any timers attached to the clock will take this into account and not continue to fire events until the clock is unpaused. (Note that this is not the same as pausing timers, which can be done manually and needs to be undone manually.)
+ * The Clock class offers a way of tracking time within a game.
+ * When creating a new Clock you should NOT directly instantiate this class
+ * but instead use the addClock method on a ClockManager.
+ * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks
+ * real world time in milliseconds elapsed since the application started.
+ * This happens automatically and there is no need to do anything to set
+ * this up.
+ * - An instance of a clock is used to track time in arbitrary units
+ * (milliseconds by default)
+ * - A clock can be started, paused, unpaused and stopped. Once stopped,
+ * re-starting the clock again will reset it. It can also have its time
+ * scale freely transformed.
+ * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer
+ * class for timer details.
+ * - If the clock is paused, any timers attached to the clock will take this
+ * into account and not continue to fire events until the clock is
+ * unpaused. (Note that this is not the same as pausing timers, which can
+ * be done manually and needs to be undone manually.)
* - Animations and TweenManagers can use any Clock.
*
* @class Clock
* @namespace Kiwi.Time
* @constructor
- * @param manager {ClockManager} The ClockManager that this clock belongs to.
- * @param master {Kiwi.Time.MasterClock} The MasterClock that it is getting the time in relation to.
- * @param name {String} The name of the clock.
- * @param [units=1000] {Number} The units that this clock is to operate in per second.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param manager {ClockManager} ClockManager that this clock belongs to
+ * @param master {Kiwi.Time.MasterClock} MasterClock that this is getting
+ * the time in relation to
+ * @param name {String} Name of the clock
+ * @param [units=1000] {Number} Units that this clock is to operate in
+ * per second
+ * @return {Kiwi.Time.Clock} This Clock object
*/
export class Clock {
@@ -44,7 +56,7 @@ module Kiwi.Time {
}
/**
- * The type of object that this is.
+ * The type of object that this is
* @method objType
* @return {String} "Clock"
* @public
@@ -54,7 +66,7 @@ module Kiwi.Time {
}
/**
- * A collection of Timer objects using this clock.
+ * Collection of Timer objects using this clock
* @property timers
* @type Timer[]
* @private
@@ -62,7 +74,7 @@ module Kiwi.Time {
private timers: Kiwi.Time.Timer[];
/**
- * The time the clock was first started relative to the master clock.
+ * Time the clock was first started relative to the master clock
* @property _timeFirstStarted
* @type Number
* @default null
@@ -71,9 +83,9 @@ module Kiwi.Time {
private _timeFirstStarted: number = null;
/**
- * The number of clock units elapsed since the clock was first started.
- * @method elapsedSinceFirstStarted.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was first started
+ * @method elapsedSinceFirstStarted
+ * @return {Number} Number of clock units elapsed
* @public
*/
public elapsedSinceFirstStarted(): number {
@@ -83,7 +95,7 @@ module Kiwi.Time {
}
/**
- * The time the clock was most recently started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @property _timeLastStarted
* @type Number
* @default null
@@ -92,9 +104,9 @@ module Kiwi.Time {
private _timeLastStarted: number = null;
/**
- * Get the most recent time the clock was started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @method started
- * @return {Number} milliseconds.
+ * @return {Number} Milliseconds
* @public
*/
public started(): number {
@@ -106,7 +118,7 @@ module Kiwi.Time {
/**
* Rate at which time passes on this clock.
- * 1 is normal speed. 0 is no speed. -1 is backwards.
+ * 1 is normal speed. 1.5 is faster. 0 is no speed. -1 is backwards.
* This mostly affects timers, animations and tweens.
* @property timeScale
* @type number
@@ -189,9 +201,10 @@ module Kiwi.Time {
/**
- * The number of clock units elapsed since the clock was most recently started (not including time spent paused)
+ * Number of clock units elapsed since the clock was most recently
+ * started (not including time spent paused)
* @method elapsed
- * @return {Number} number of clock units.
+ * @return {Number} Number of clock units
* @public
*/
public elapsed(): number {
@@ -199,7 +212,8 @@ module Kiwi.Time {
}
/**
- * The time the clock was most recently stopped relative to the master clock.
+ * Time the clock was most recently stopped relative to the
+ * master clock.
* @property _timeLastStopped
* @type Number
* @default null
@@ -208,9 +222,10 @@ module Kiwi.Time {
private _timeLastStopped: number = null;
/**
- * The number of clock units elapsed since the clock was most recently stopped.
- * @method elapsedSinceLastStopped.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * stopped.
+ * @method elapsedSinceLastStopped
+ * @return {Number} Number of clock units
* @public
*/
public elapsedSinceLastStopped(): number {
@@ -220,7 +235,8 @@ module Kiwi.Time {
}
/**
- * The time the clock was most receently paused relative to the master clock.
+ * Time the clock was most receently paused relative to the
+ * master clock.
* @property _timeLastPaused
* @private
* @type Number
@@ -230,9 +246,9 @@ module Kiwi.Time {
private _timeLastPaused: number = null;
/**
- * The number of clock units elapsed since the clock was most recently paused.
- * @method elapsedSinceLastPaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently paused.
+ * @method elapsedSinceLastPaused
+ * @return {Number} Number of clock units
* @public
*/
public elapsedSinceLastPaused(): number {
@@ -242,7 +258,8 @@ module Kiwi.Time {
}
/**
- * The time the clock was most recently unpaused relative to the master clock.
+ * Time the clock was most recently unpaused relative to the
+ * master clock.
* @property _timeLastUnpaused
* @private
* @type Number
@@ -252,9 +269,10 @@ module Kiwi.Time {
private _timeLastUnpaused: number = null;
/**
- * The number of clock units elapsed since the clock was most recently unpaused.
- * @method elapsedSinceLastUnpaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * unpaused.
+ * @method elapsedSinceLastUnpaused
+ * @return {Number} Number of clock units
* @public
*/
public elapsedSinceLastUnpaused(): number {
@@ -264,7 +282,8 @@ module Kiwi.Time {
}
/**
- * The total number of milliseconds the clock has been paused since it was last started.
+ * Total number of milliseconds the clock has been paused
+ * since it was last started
* @property _totalPaused
* @private
* @type Number
@@ -274,7 +293,7 @@ module Kiwi.Time {
private _totalPaused: number = 0;
/**
- * Whether the clock is in a running state.
+ * Whether the clock is in a running state
* @property _isRunning
* @type boolean
* @default false
@@ -283,9 +302,9 @@ module Kiwi.Time {
private _isRunning: boolean = false;
/**
- * Check if the clock is currently running.
+ * Check if the clock is currently running
* @method isRunning
- * @return {boolean} true if running.
+ * @return {boolean} `true` if running
* @public
*/
public isRunning(): boolean {
@@ -295,7 +314,7 @@ module Kiwi.Time {
}
/**
- * Whether the clock is in a stopped state.
+ * Whether the clock is in a stopped state
* @property _isStopped
* @type boolean
* @default true
@@ -304,9 +323,9 @@ module Kiwi.Time {
private _isStopped: boolean = true;
/**
- * Check if the clock is in the stopped state.
+ * Check if the clock is in the stopped state
* @method isStopped
- * @return {boolean} true if stopped.
+ * @return {boolean} `true` if stopped
* @public
*/
public isStopped(): boolean {
@@ -316,7 +335,7 @@ module Kiwi.Time {
}
/**
- * Whether the clock is in a paused state.
+ * Whether the clock is in a paused state
* @property _isPaused
* @type boolean
* @default false
@@ -325,9 +344,9 @@ module Kiwi.Time {
private _isPaused: boolean = false;
/**
- * Check if the clock is in the paused state.
+ * Check if the clock is in the paused state
* @method isPaused
- * @return {boolean} true if paused.
+ * @return {boolean} `true` if paused
* @public
*/
public isPaused(): boolean {
@@ -337,7 +356,7 @@ module Kiwi.Time {
}
/**
- * An internal reference to the state of the elapsed timer
+ * Internal reference to the state of the elapsed timer
* @property _elapsedState
* @type Number
* @private
@@ -345,7 +364,7 @@ module Kiwi.Time {
private _elapsedState: number = Kiwi.Time.Clock._RUNNING;
/**
- * The time manager that this clock belongs to.
+ * Time manager that this clock belongs to
* @property manager
* @type ClockManager
* @public
@@ -353,7 +372,7 @@ module Kiwi.Time {
public manager: Kiwi.Time.ClockManager = null;
/**
- * The master clock.
+ * Master clock from which time is derived
* @property master
* @type Kiwi.Time.MasterClock
* @public
@@ -369,7 +388,7 @@ module Kiwi.Time {
public name: string = null;
/**
- * The number of milliseconds counted as one unit of time by the clock.
+ * Number of milliseconds counted as one unit of time by the clock
* @property units
* @type Number
* @default 0
@@ -422,8 +441,8 @@ module Kiwi.Time {
/**
* Add an existing Timer to the Clock.
* @method addTimer
- * @param timer {Timer} Timer object instance to be added to this Clock.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param timer {Timer} Timer object instance to be added to this Clock
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
public addTimer(timer: Timer): Clock {
@@ -434,13 +453,15 @@ module Kiwi.Time {
}
/**
- * Creates a new Timer and adds it to this Clock.
+ * Create a new Timer and add it to this Clock.
* @method createTimer
- * @param name {string} The name of the Timer (must be unique on this Clock).
- * @param [delay=1] {Number} The number of clock units to wait between firing events (default 1)
- * @param [repeatCount=0] {Number} The number of times to repeat this Timer (default 0)
- * @param [start=true] {Boolean} If the timer should start.
- * @return {Kiwi.Time.Timer} The newly created Timer.
+ * @param name {string} Name of the Timer (must be unique on this Clock)
+ * @param [delay=1] {Number} Number of clock units to wait between
+ * firing events
+ * @param [repeatCount=0] {Number} Number of times to repeat the Timer
+ * (default 0)
+ * @param [start=true] {Boolean} If the timer should start
+ * @return {Kiwi.Time.Timer} The newly created Timer
* @public
*/
public createTimer(name: string, delay: number = 1, repeatCount: number = 0, start: boolean=true): Timer {
@@ -456,11 +477,13 @@ module Kiwi.Time {
}
/**
- * Remove a Timer from this Clock based on either the Timer object or its name.
+ * Remove a Timer from this Clock based on either the Timer object
+ * or its name.
* @method removeTimer
- * @param [timer=null] {Timer} The Timer object you wish to remove. If you wish to delete by Timer Name set this to null.
- * @param [timerName=''] {string} The name of the Timer object to remove.
- * @return {boolean} True if the Timer was successfully removed, false if not.
+ * @param [timer=null] {Timer} Timer object you wish to remove.
+ * If you wish to delete by Timer Name set this to null.
+ * @param [timerName=''] {string} Name of the Timer object to remove
+ * @return {boolean} `true` if the Timer was successfully removed
* @public
*/
public removeTimer(timer: Timer = null, timerName:string = ""): boolean {
@@ -486,10 +509,10 @@ module Kiwi.Time {
}
/**
- * Check if the Timer already exists on this Clock
+ * Check if the Timer already exists on this Clock.
* @method checkExists
- * @param name {string} The name of the Timer.
- * @return {boolean} true if the Timer exists, false if not.
+ * @param name {string} Name of the Timer
+ * @return {boolean} `true` if the Timer exists
* @public
*/
public checkExists(name: string): boolean {
@@ -508,7 +531,7 @@ module Kiwi.Time {
/**
* Stop all timers attached to the clock.
* @method stopAllTimers
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
public stopAllTimers(): Clock {
@@ -524,9 +547,9 @@ module Kiwi.Time {
/**
* Convert a number to milliseconds based on clock units.
- * @method toMilliseconds.
- * @param time {number} seconds
- * @return {Number} milliseconds.
+ * @method toMilliseconds
+ * @param time {number} Seconds
+ * @return {Number} Milliseconds
* @public
*/
public convertToMilliseconds(time: number): number {
@@ -536,7 +559,7 @@ module Kiwi.Time {
}
/**
- * Updates all Timers linked to this Clock.
+ * Update all Timers linked to this Clock.
* @method update
* @public
*/
@@ -571,7 +594,7 @@ module Kiwi.Time {
/**
* Start the clock. This resets the clock and starts it running.
* @method start
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
public start(): Clock {
@@ -590,14 +613,18 @@ module Kiwi.Time {
this._elapsedState = Kiwi.Time.Clock._RUNNING;
+ this._elapsed = 0;
+ this._lastMasterElapsed = this.master.elapsed();
+ this._currentMasterElapsed = this.master.elapsed();
+
return this;
}
/**
- * Pause the clock. The clock can only be paused if it is already running.
+ * Pause the clock. This can only be paused if it is already running.
* @method pause
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
public pause(): Clock {
@@ -616,9 +643,9 @@ module Kiwi.Time {
}
/**
- * Resume the clock. The clock can only be resumed if it is already paused.
+ * Resume the clock. This can only be resumed if it is already paused.
* @method resume
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
public resume(): Clock {
@@ -639,9 +666,10 @@ module Kiwi.Time {
}
/**
- * Stop the clock. Clock can only be stopped if it is already running or is paused.
+ * Stop the clock. This can only be stopped if it is already running
+ * or is paused.
* @method stop
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
public stop(): Clock {
@@ -667,9 +695,9 @@ module Kiwi.Time {
}
/**
- * Returns a string representation of this object.
+ * Return a string representation of this object.
* @method toString
- * @return {string} a string representation of the instance.
+ * @return {string} String representation of the instance
* @public
*/
public toString(): string {
@@ -681,24 +709,24 @@ module Kiwi.Time {
/**
* Set a function to execute after a certain time interval.
- * Emulates window.setTimeout, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setTimeout`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearTimeout is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearTimeout` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setTimeout
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds before execution
- * @param [context] {object} Object to be "this" for the callback
- * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used to further
- * manipulate the timer
+ * @param [context] {object} Object to be `this` for the callback
+ * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used
+ * to further manipulate the timer
* @public
*/
public setTimeout( callback, timeout: number, context, ...args ): Timer {
@@ -724,22 +752,22 @@ module Kiwi.Time {
/**
* Set a function to repeatedly execute at fixed time intervals.
- * Emulates window.setInterval, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setInterval`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearInterval is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearInterval` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setInterval
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds between executions
- * @param [context=window] {object} Object to be "this" for the callback
+ * @param [context=window] {object} Object to be `this` for the callback
* @return {Kiwi.Time.Timer} Kiwi.Time.Timer object
* which can be used to further manipulate the timer
* @public
View
272 templateGame/lib/kiwi.js
@@ -2811,6 +2811,7 @@ var Kiwi;
* @property inputEnabled
* @type boolean
* @public
+ * @deprecated As of 1.2.3, nothing was found to use this.
*/
set: function (value) {
this._inputEnabled = value;
@@ -8659,10 +8660,13 @@ var Kiwi;
this._callbackContext = callbackContext;
};
/**
- * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component.
+ * Sets the parent's rotation to be equal to the trajectory of the
+ * velocity of the physics component. Note that rotation 0 corresponds
+ * to pointing directly to the right.
* @method rotateToVelocity
- * @return { Number }
+ * @return {number} New rotation value
* @public
+ * @since 1.3.0
*/
ArcadePhysics.prototype.rotateToVelocity = function () {
var result = Math.atan2(this.velocity.y, this.velocity.x);
@@ -21317,14 +21321,20 @@ var Kiwi;
};
/**
* Check to see if a Line and a Line Segment intersect at any point.
- * Note: The first line passed is treated as if it extends infinately though space,
- * The second is treated as if it only exists between its two points.
+ * Note: The first line passed is treated as if it extends infinitely
+ * though space. The second is treated as if it only exists between
+ * its two points.
*
* @method lineToLineSegment
- * @param line1 {Kiwi.Geom.Line} The first line to check. This is the one that will extend through space infinately.
- * @param seg {Kiwi.Geom.Line} The second line to check. This is the one that will only exist between its two coordinates.
- * @param [output] {Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection.
+ * @param line1 {Kiwi.Geom.Line} The first line to check.
+ This is the one that will extend through space infinately.
+ * @param seg {Kiwi.Geom.Line} The second line to check.
+ This is the one that will only exist between its two coordinates.
+ * @param [output] {Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in. One is
+ created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection.
* @public
* @static
*/
@@ -21339,8 +21349,7 @@ var Kiwi;
var minX = Math.min(seg.x1, seg.x2);
var maxY = Math.max(seg.y1, seg.y2);
var minY = Math.min(seg.y1, seg.y2);
- //if (!(output.x <= maxX && output.x >= minX) || !(output.y <= maxY && output.y >= minY))
- if ((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true) {
+ if ((output.x <= maxX && output.x >= minX) === true && (output.y <= maxY && output.y >= minY) === true) {
output.result = true;
}
}
@@ -21495,19 +21504,23 @@ var Kiwi;
return output;
};
/**
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
* Line Segment
- * -------------------------------------------------------------------------------------------
+ * ---------------------------------------------------------------------
**/
/**
* Checks to see if two Line Segments intersect at any point in space.
- * Note: Both lines are treated as if they only exist between their two line coordinates.
+ * Note: Both lines are treated as if they only exist between their two
+ * line coordinates.
*
* @method lineSegmentToLineSegment
* @param line1 {Kiwi.Geom.Line} The first line object to check.
* @param line2 {Kiwi.Geom.Line} The second line object to check.
- * @param [output]{Kiwi.Geom.IntersectResult} An optional IntersectResult object to store the intersection values in. One is created if none given.
- * @return {Kiwi.Geom.IntersectResult} An IntersectResult object containing the results of this intersection in x/y.
+ * @param [output]{Kiwi.Geom.IntersectResult} An optional
+ IntersectResult object to store the intersection values in.
+ One is created if none given.
+ * @return {Kiwi.Geom.IntersectResult} An IntersectResult object
+ containing the results of this intersection in x/y.
* @public
* @static
*/
@@ -27894,38 +27907,50 @@ var Kiwi;
})(Sound = Kiwi.Sound || (Kiwi.Sound = {}));
})(Kiwi || (Kiwi = {}));
/**
-*
* @module Kiwi
* @submodule Time
-*
*/
var Kiwi;
(function (Kiwi) {
var Time;
(function (Time) {
/**
- * The Clock class offers a way of tracking time within a game. When creating a new Clock you should NOT directly instantiate this class but instead use the addClock method on a ClockManager.
- * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks real world time in milliseconds elapsed since the application started. This happens automatically and there is no need to do anything to set this up.
- * - An instance of a clock is used to track time in arbitrary units (milliseconds by default)
- * - A clock can be started, paused, unpaused and stopped. Once stopped, re-starting the clock again will reset it. It can also have its time scale freely transformed.
- * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer class for timer details.
- * - If the clock is paused, any timers attached to the clock will take this into account and not continue to fire events until the clock is unpaused. (Note that this is not the same as pausing timers, which can be done manually and needs to be undone manually.)
+ * The Clock class offers a way of tracking time within a game.
+ * When creating a new Clock you should NOT directly instantiate this class
+ * but instead use the addClock method on a ClockManager.
+ * - The MasterClock is a property of the Kiwi.Time.Manager class and tracks
+ * real world time in milliseconds elapsed since the application started.
+ * This happens automatically and there is no need to do anything to set
+ * this up.
+ * - An instance of a clock is used to track time in arbitrary units
+ * (milliseconds by default)
+ * - A clock can be started, paused, unpaused and stopped. Once stopped,
+ * re-starting the clock again will reset it. It can also have its time
+ * scale freely transformed.
+ * - Any number of timers can be attached to a clock. See the Kiwi.Time.Timer
+ * class for timer details.
+ * - If the clock is paused, any timers attached to the clock will take this
+ * into account and not continue to fire events until the clock is
+ * unpaused. (Note that this is not the same as pausing timers, which can
+ * be done manually and needs to be undone manually.)
* - Animations and TweenManagers can use any Clock.
*
* @class Clock
* @namespace Kiwi.Time
* @constructor
- * @param manager {ClockManager} The ClockManager that this clock belongs to.
- * @param master {Kiwi.Time.MasterClock} The MasterClock that it is getting the time in relation to.
- * @param name {String} The name of the clock.
- * @param [units=1000] {Number} The units that this clock is to operate in per second.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param manager {ClockManager} ClockManager that this clock belongs to
+ * @param master {Kiwi.Time.MasterClock} MasterClock that this is getting
+ * the time in relation to
+ * @param name {String} Name of the clock
+ * @param [units=1000] {Number} Units that this clock is to operate in
+ * per second
+ * @return {Kiwi.Time.Clock} This Clock object
*/
var Clock = (function () {
function Clock(manager, master, name, units) {
if (units === void 0) { units = 1000; }
/**
- * The time the clock was first started relative to the master clock.
+ * Time the clock was first started relative to the master clock
* @property _timeFirstStarted
* @type Number
* @default null
@@ -27933,7 +27958,7 @@ var Kiwi;
*/
this._timeFirstStarted = null;
/**
- * The time the clock was most recently started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @property _timeLastStarted
* @type Number
* @default null
@@ -27942,7 +27967,7 @@ var Kiwi;
this._timeLastStarted = null;
/**
* Rate at which time passes on this clock.
- * 1 is normal speed. 0 is no speed. -1 is backwards.
+ * 1 is normal speed. 1.5 is faster. 0 is no speed. -1 is backwards.
* This mostly affects timers, animations and tweens.
* @property timeScale
* @type number
@@ -27983,7 +28008,8 @@ var Kiwi;
*/
this._maxFrameDuration = -1;
/**
- * The time the clock was most recently stopped relative to the master clock.
+ * Time the clock was most recently stopped relative to the
+ * master clock.
* @property _timeLastStopped
* @type Number
* @default null
@@ -27991,7 +28017,8 @@ var Kiwi;
*/
this._timeLastStopped = null;
/**
- * The time the clock was most receently paused relative to the master clock.
+ * Time the clock was most receently paused relative to the
+ * master clock.
* @property _timeLastPaused
* @private
* @type Number
@@ -28000,7 +28027,8 @@ var Kiwi;
*/
this._timeLastPaused = null;
/**
- * The time the clock was most recently unpaused relative to the master clock.
+ * Time the clock was most recently unpaused relative to the
+ * master clock.
* @property _timeLastUnpaused
* @private
* @type Number
@@ -28009,7 +28037,8 @@ var Kiwi;
*/
this._timeLastUnpaused = null;
/**
- * The total number of milliseconds the clock has been paused since it was last started.
+ * Total number of milliseconds the clock has been paused
+ * since it was last started
* @property _totalPaused
* @private
* @type Number
@@ -28018,7 +28047,7 @@ var Kiwi;
*/
this._totalPaused = 0;
/**
- * Whether the clock is in a running state.
+ * Whether the clock is in a running state
* @property _isRunning
* @type boolean
* @default false
@@ -28026,7 +28055,7 @@ var Kiwi;
*/
this._isRunning = false;
/**
- * Whether the clock is in a stopped state.
+ * Whether the clock is in a stopped state
* @property _isStopped
* @type boolean
* @default true
@@ -28034,7 +28063,7 @@ var Kiwi;
*/
this._isStopped = true;
/**
- * Whether the clock is in a paused state.
+ * Whether the clock is in a paused state
* @property _isPaused
* @type boolean
* @default false
@@ -28042,21 +28071,21 @@ var Kiwi;
*/
this._isPaused = false;
/**
- * An internal reference to the state of the elapsed timer
+ * Internal reference to the state of the elapsed timer
* @property _elapsedState
* @type Number
* @private
*/
this._elapsedState = Kiwi.Time.Clock._RUNNING;
/**
- * The time manager that this clock belongs to.
+ * Time manager that this clock belongs to
* @property manager
* @type ClockManager
* @public
*/
this.manager = null;
/**
- * The master clock.
+ * Master clock from which time is derived
* @property master
* @type Kiwi.Time.MasterClock
* @public
@@ -28070,7 +28099,7 @@ var Kiwi;
*/
this.name = null;
/**
- * The number of milliseconds counted as one unit of time by the clock.
+ * Number of milliseconds counted as one unit of time by the clock
* @property units
* @type Number
* @default 0
@@ -28089,7 +28118,7 @@ var Kiwi;
this._currentMasterElapsed = this.master.elapsed();
}
/**
- * The type of object that this is.
+ * The type of object that this is
* @method objType
* @return {String} "Clock"
* @public
@@ -28098,18 +28127,18 @@ var Kiwi;
return "Clock";
};
/**
- * The number of clock units elapsed since the clock was first started.
- * @method elapsedSinceFirstStarted.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was first started
+ * @method elapsedSinceFirstStarted
+ * @return {Number} Number of clock units elapsed
* @public
*/
Clock.prototype.elapsedSinceFirstStarted = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeFirstStarted) / this.units : null;
};
/**
- * Get the most recent time the clock was started relative to the master clock.
+ * Most recent time the clock was started relative to the master clock
* @method started
- * @return {Number} milliseconds.
+ * @return {Number} Milliseconds
* @public
*/
Clock.prototype.started = function () {
@@ -28136,63 +28165,66 @@ var Kiwi;
configurable: true
});
/**
- * The number of clock units elapsed since the clock was most recently started (not including time spent paused)
+ * Number of clock units elapsed since the clock was most recently
+ * started (not including time spent paused)
* @method elapsed
- * @return {Number} number of clock units.
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsed = function () {
return this._elapsed;
};
/**
- * The number of clock units elapsed since the clock was most recently stopped.
- * @method elapsedSinceLastStopped.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * stopped.
+ * @method elapsedSinceLastStopped
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsedSinceLastStopped = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeLastStopped) / this.units : null;
};
/**
- * The number of clock units elapsed since the clock was most recently paused.
- * @method elapsedSinceLastPaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently paused.
+ * @method elapsedSinceLastPaused
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsedSinceLastPaused = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeLastPaused) / this.units : null;
};
/**
- * The number of clock units elapsed since the clock was most recently unpaused.
- * @method elapsedSinceLastUnpaused.
- * @return {Number} number of clock units.
+ * Number of clock units elapsed since the clock was most recently
+ * unpaused.
+ * @method elapsedSinceLastUnpaused
+ * @return {Number} Number of clock units
* @public
*/
Clock.prototype.elapsedSinceLastUnpaused = function () {
return (this._timeLastStarted) ? (this.master.elapsed() - this._timeLastUnpaused) / this.units : null;
};
/**
- * Check if the clock is currently running.
+ * Check if the clock is currently running
* @method isRunning
- * @return {boolean} true if running.
+ * @return {boolean} `true` if running
* @public
*/
Clock.prototype.isRunning = function () {
return this._isRunning;
};
/**
- * Check if the clock is in the stopped state.
+ * Check if the clock is in the stopped state
* @method isStopped
- * @return {boolean} true if stopped.
+ * @return {boolean} `true` if stopped
* @public
*/
Clock.prototype.isStopped = function () {
return this._isStopped;
};
/**
- * Check if the clock is in the paused state.
+ * Check if the clock is in the paused state
* @method isPaused
- * @return {boolean} true if paused.
+ * @return {boolean} `true` if paused
* @public
*/
Clock.prototype.isPaused = function () {
@@ -28201,8 +28233,8 @@ var Kiwi;
/**
* Add an existing Timer to the Clock.
* @method addTimer
- * @param timer {Timer} Timer object instance to be added to this Clock.
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @param timer {Timer} Timer object instance to be added to this Clock
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.addTimer = function (timer) {
@@ -28210,13 +28242,15 @@ var Kiwi;
return this;
};
/**
- * Creates a new Timer and adds it to this Clock.
+ * Create a new Timer and add it to this Clock.
* @method createTimer
- * @param name {string} The name of the Timer (must be unique on this Clock).
- * @param [delay=1] {Number} The number of clock units to wait between firing events (default 1)
- * @param [repeatCount=0] {Number} The number of times to repeat this Timer (default 0)
- * @param [start=true] {Boolean} If the timer should start.
- * @return {Kiwi.Time.Timer} The newly created Timer.
+ * @param name {string} Name of the Timer (must be unique on this Clock)
+ * @param [delay=1] {Number} Number of clock units to wait between
+ * firing events
+ * @param [repeatCount=0] {Number} Number of times to repeat the Timer
+ * (default 0)
+ * @param [start=true] {Boolean} If the timer should start
+ * @return {Kiwi.Time.Timer} The newly created Timer
* @public
*/
Clock.prototype.createTimer = function (name, delay, repeatCount, start) {
@@ -28230,11 +28264,13 @@ var Kiwi;
return this.timers[this.timers.length - 1];
};
/**
- * Remove a Timer from this Clock based on either the Timer object or its name.
+ * Remove a Timer from this Clock based on either the Timer object
+ * or its name.
* @method removeTimer
- * @param [timer=null] {Timer} The Timer object you wish to remove. If you wish to delete by Timer Name set this to null.
- * @param [timerName=''] {string} The name of the Timer object to remove.
- * @return {boolean} True if the Timer was successfully removed, false if not.
+ * @param [timer=null] {Timer} Timer object you wish to remove.
+ * If you wish to delete by Timer Name set this to null.
+ * @param [timerName=''] {string} Name of the Timer object to remove
+ * @return {boolean} `true` if the Timer was successfully removed
* @public
*/
Clock.prototype.removeTimer = function (timer, timerName) {
@@ -28260,10 +28296,10 @@ var Kiwi;
return false;
};
/**
- * Check if the Timer already exists on this Clock
+ * Check if the Timer already exists on this Clock.
* @method checkExists
- * @param name {string} The name of the Timer.
- * @return {boolean} true if the Timer exists, false if not.
+ * @param name {string} Name of the Timer
+ * @return {boolean} `true` if the Timer exists
* @public
*/
Clock.prototype.checkExists = function (name) {
@@ -28277,7 +28313,7 @@ var Kiwi;
/**
* Stop all timers attached to the clock.
* @method stopAllTimers
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
Clock.prototype.stopAllTimers = function () {
@@ -28288,16 +28324,16 @@ var Kiwi;
};
/**
* Convert a number to milliseconds based on clock units.
- * @method toMilliseconds.
- * @param time {number} seconds
- * @return {Number} milliseconds.
+ * @method toMilliseconds
+ * @param time {number} Seconds
+ * @return {Number} Milliseconds
* @public
*/
Clock.prototype.convertToMilliseconds = function (time) {
return time * this.units;
};
/**
- * Updates all Timers linked to this Clock.
+ * Update all Timers linked to this Clock.
* @method update
* @public
*/
@@ -28330,7 +28366,7 @@ var Kiwi;
/**
* Start the clock. This resets the clock and starts it running.
* @method start
- * @return {Clock} This Clock object.
+ * @return {Clock} This Clock object
* @public
*/
Clock.prototype.start = function () {
@@ -28343,12 +28379,15 @@ var Kiwi;
this._isPaused = false;
this._isStopped = false;
this._elapsedState = Kiwi.Time.Clock._RUNNING;
+ this._elapsed = 0;
+ this._lastMasterElapsed = this.master.elapsed();
+ this._currentMasterElapsed = this.master.elapsed();
return this;
};
/**
- * Pause the clock. The clock can only be paused if it is already running.
+ * Pause the clock. This can only be paused if it is already running.
* @method pause
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.pause = function () {
@@ -28362,9 +28401,9 @@ var Kiwi;
return this;
};
/**
- * Resume the clock. The clock can only be resumed if it is already paused.
+ * Resume the clock. This can only be resumed if it is already paused.
* @method resume
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.resume = function () {
@@ -28379,9 +28418,10 @@ var Kiwi;
return this;
};
/**
- * Stop the clock. Clock can only be stopped if it is already running or is paused.
+ * Stop the clock. This can only be stopped if it is already running
+ * or is paused.
* @method stop
- * @return {Kiwi.Time.Clock} This Clock object.
+ * @return {Kiwi.Time.Clock} This Clock object
* @public
*/
Clock.prototype.stop = function () {
@@ -28398,9 +28438,9 @@ var Kiwi;
return this;
};
/**
- * Returns a string representation of this object.
+ * Return a string representation of this object.
* @method toString
- * @return {string} a string representation of the instance.
+ * @return {string} String representation of the instance
* @public
*/
Clock.prototype.toString = function () {
@@ -28408,24 +28448,24 @@ var Kiwi;
};
/**
* Set a function to execute after a certain time interval.
- * Emulates window.setTimeout, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setTimeout`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearTimeout is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearTimeout` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setTimeout
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds before execution
- * @param [context] {object} Object to be "this" for the callback
- * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used to further
- * manipulate the timer
+ * @param [context] {object} Object to be `this` for the callback
+ * @return {Kiwi.Time.Timer} Kiwi.Time.Timer object which can be used
+ * to further manipulate the timer
* @public
*/
Clock.prototype.setTimeout = function (callback, timeout, context) {
@@ -28446,22 +28486,22 @@ var Kiwi;
};
/**
* Set a function to repeatedly execute at fixed time intervals.
- * Emulates window.setInterval, except attached to a Kiwi.Time.Clock.
- * This allows you to pause and manipulate time, and the timeout will respect
- * the clock on which it is created.
+ * Emulates `window.setInterval`, except attached to a `Kiwi.Time.Clock`.
+ * This allows you to pause and manipulate time, and the timeout will
+ * respect the clock on which it is created.
*
- * No clearInterval is provided; you should use Kiwi.Time.Timer functions
- * to achieve further control.
+ * No `clearInterval` is provided; you should use `Kiwi.Time.Timer`
+ * functions to achieve further control.
*
- * Any parameters after "context" will be passed as parameters to the
- * callback function. Note that you must specify "context" in order for
- * this to work. You may specify "null", in which case it will default
- * to the global scope "window".
+ * Any parameters after `context` will be passed as parameters to the
+ * callback function. Note that you must specify `context` in order for
+ * this to work. You may specify `null`, in which case it will default
+ * to the global scope `window`.
*
* @method setInterval
* @param callback {function} Function to execute
* @param timeout {number} Milliseconds between executions
- * @param [context=window] {object} Object to be "this" for the callback
+ * @param [context=window] {object} Object to be `this` for the callback
* @return {Kiwi.Time.Timer} Kiwi.Time.Timer object
* which can be used to further manipulate the timer
* @public

0 comments on commit 78db0c3

Please sign in to comment.
Something went wrong with that request. Please try again.