├── .gitignore ├── LICENSE ├── README.md ├── build.sbt ├── project ├── build.properties └── plugins.sbt └── src └── main └── scala └── io └── scalajs └── dom └── html └── phaser ├── Animation.scala ├── AnimationManager.scala ├── ArraySet.scala ├── AudioSprite.scala ├── BitmapData.scala ├── BitmapText.scala ├── Bullet.scala ├── Button.scala ├── Cache.scala ├── Camera.scala ├── Canvas.scala ├── Circle.scala ├── Create.scala ├── CursorKeys.scala ├── Device.scala ├── DeviceButton.scala ├── Easing.scala ├── Ellipse.scala ├── Events.scala ├── Frame.scala ├── FrameData.scala ├── Game.scala ├── GameConfigObject.scala ├── GameObjectCreator.scala ├── GameObjectFactory.scala ├── GameState.scala ├── Gamepad.scala ├── Graphics.scala ├── Group.scala ├── Image.scala ├── Input.scala ├── InputHandler.scala ├── Key.scala ├── Keyboard.scala ├── Line.scala ├── Linear.scala ├── Loader.scala ├── Math.scala ├── Phaser.scala ├── Physics.scala ├── Plugin.scala ├── PluginManager.scala ├── Point.scala ├── Pointer.scala ├── PointerMode.scala ├── Polygon.scala ├── QuadTree.scala ├── RandomDataGenerator.scala ├── Rectangle.scala ├── RenderTexture.scala ├── RoundedRectangle.scala ├── ScaleManager.scala ├── Signal.scala ├── SignalBinding.scala ├── SinglePad.scala ├── Sound.scala ├── SoundManager.scala ├── Sprite.scala ├── State.scala ├── Text.scala ├── Texture.scala ├── TileSprite.scala ├── Tilemap.scala ├── TilemapLayer.scala ├── Time.scala ├── Timer.scala ├── TimerEvent.scala ├── Tween.scala ├── Video.scala ├── Weapon.scala ├── World.scala ├── component ├── Angle.scala ├── Animation.scala ├── AutoCull.scala ├── Bounds.scala ├── BringToTop.scala ├── Core.scala ├── Crop.scala ├── Delta.scala ├── Destroy.scala ├── FixedToCamera.scala ├── Health.scala ├── InCamera.scala ├── InWorld.scala ├── InputEnabled.scala ├── LifeSpan.scala ├── LoadTexture.scala ├── Overlap.scala ├── PhysicsBody.scala ├── Reset.scala ├── ScaleMinMax.scala └── Smoothed.scala ├── package.scala ├── physics ├── Arcade.scala ├── Box2D.scala ├── Chipmunk.scala ├── Matter.scala ├── Ninja.scala ├── P2.scala ├── arcade │ └── Body.scala ├── ninja │ ├── AABB.scala │ └── Body.scala └── p2 │ └── Material.scala └── utils ├── ArrayUtils.scala ├── Debug.scala └── Utils.scala /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Scala template 3 | *.class 4 | *.log 5 | 6 | # sbt specific 7 | .cache 8 | .history 9 | .lib/ 10 | dist/* 11 | target/ 12 | lib_managed/ 13 | src_managed/ 14 | project/boot/ 15 | project/plugins/project/ 16 | 17 | # Scala-IDE specific 18 | .scala_dependencies 19 | .worksheet 20 | 21 | # ENSIME specific 22 | .ensime_cache/ 23 | .ensime 24 | ### SBT template 25 | # Simple Build Tool 26 | # http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control 27 | 28 | target/ 29 | lib_managed/ 30 | src_managed/ 31 | project/boot/ 32 | .history 33 | .cache 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Phaser.js API for Scala.js 2 | ================================ 3 | [phaser](http://phaser.io/docs/2.6.2/) - A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers. 4 | 5 | ### Description 6 | 7 | Phaser is a fast, free, and fun open source HTML5 game framework. It uses a custom build of Pixi.js for 8 | WebGL and Canvas rendering, and supports desktop and mobile web browsers. Games can be compiled to iOS, 9 | Android and native desktop apps via 3rd party tools. You can use JavaScript or TypeScript for development. 10 | 11 | Along with the fantastic open source community, Phaser is actively developed and maintained by Photon Storm. 12 | As a result of rapid support, and a developer friendly API, Phaser is currently one of the most starred game 13 | frameworks on GitHub. 14 | 15 | Thousands of developers worldwide use Phaser. From indies and multi-national digital agencies, to schools 16 | and Universities. Each creating their own incredible games. 17 | 18 | ### Build Requirements 19 | 20 | * [SBT v1.2.x](http://www.scala-sbt.org/download.html) 21 | 22 | ### Build/publish the SDK locally 23 | 24 | ```bash 25 | $ sbt clean publish-local 26 | ``` 27 | 28 | ### Running the tests 29 | 30 | Before running the tests the first time, you must ensure the npm packages are installed: 31 | 32 | ```bash 33 | $ npm install 34 | ``` 35 | 36 | Then you can run the tests: 37 | 38 | ```bash 39 | $ sbt test 40 | ``` 41 | 42 | ### Artifacts and Resolvers 43 | 44 | To add the `Phaser` binding to your project, add the following to your build.sbt: 45 | 46 | ```sbt 47 | libraryDependencies += "io.scalajs.npm" %%% "phaser" % "0.5.0" 48 | ``` 49 | 50 | Optionally, you may add the Sonatype Repository resolver: 51 | 52 | ```sbt 53 | resolvers += Resolver.sonatypeRepo("releases") 54 | ``` 55 | -------------------------------------------------------------------------------- /build.sbt: -------------------------------------------------------------------------------- 1 | import org.scalajs.sbtplugin.ScalaJSPlugin 2 | import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ 3 | import sbt.Keys.{libraryDependencies, _} 4 | import sbt.Project.projectToRef 5 | import sbt._ 6 | 7 | import scala.language.postfixOps 8 | 9 | val scalaJsIOVersion = "0.5.0" 10 | val apiVersion = scalaJsIOVersion 11 | val scalaJsVersion = "2.12.8" 12 | 13 | organization := "io.scalajs" 14 | 15 | homepage := Some(url("https://github.com/scalajs-io/phaser")) 16 | 17 | lazy val root = (project in file(".")). 18 | enablePlugins(ScalaJSPlugin). 19 | settings( 20 | name := "phaser", 21 | organization := "io.scalajs", 22 | description := "Scalajs.io Phaser.js 3.x bindings", 23 | version := apiVersion, 24 | scalaVersion := scalaJsVersion, 25 | scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-language:implicitConversions", "-Xlint"), 26 | scalacOptions in(Compile, doc) ++= Seq("-no-link-warnings"), 27 | scalacOptions += "-P:scalajs:sjsDefinedByDefault", 28 | autoCompilerPlugins := true, 29 | scalaJSModuleKind := ModuleKind.CommonJSModule, 30 | libraryDependencies ++= Seq( 31 | "org.scala-lang" % "scala-reflect" % scalaJsVersion, 32 | "org.scalatest" %%% "scalatest" % "3.0.1" % "test", 33 | "io.scalajs" %%% "pixijs" % scalaJsIOVersion 34 | )) 35 | 36 | ///////////////////////////////////////////////////////////////////////////////// 37 | // Publishing 38 | ///////////////////////////////////////////////////////////////////////////////// 39 | 40 | lazy val publishingSettings = Seq( 41 | sonatypeProfileName := "org.xerial", 42 | publishMavenStyle := true, 43 | publishTo := { 44 | val nexus = "https://oss.sonatype.org/" 45 | if (isSnapshot.value) 46 | Some("snapshots" at nexus + "content/repositories/snapshots") 47 | else 48 | Some("releases" at nexus + "service/local/staging/deploy/maven2") 49 | }, 50 | pomExtra := 51 | https://github.com/scalajs-io/phaser 52 | 53 | 54 | MIT License 55 | http://www.opensource.org/licenses/mit-license.php 56 | 57 | 58 | 59 | scm:git:github.com/scalajs-io/phaser.git 60 | scm:git:git@github.com:scalajs-io/phaser.git 61 | github.com/scalajs-io/phaser.git 62 | 63 | 64 | 65 | ldaniels528 66 | Lawrence Daniels 67 | lawrence.daniels@gmail.com 68 | io.scalajs 69 | https://github.com/ldaniels528 70 | 71 | Project-Administrator 72 | Developer 73 | 74 | +7 75 | 76 | 77 | ) 78 | 79 | // loads the Scalajs-io root project at sbt startup 80 | onLoad in Global := (Command.process("project root", _: State)) compose (onLoad in Global).value -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.16 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | // Scala.js 2 | 3 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28") 4 | 5 | // Publishing 6 | 7 | addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3") 8 | 9 | addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") 10 | 11 | // Resolvers 12 | 13 | ////addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.5.5") 14 | 15 | resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" 16 | 17 | resolvers += Resolver.url("scala-js-snapshots", url("http://repo.scala-js.org/repo/snapshots/"))( 18 | Resolver.ivyStylePatterns) 19 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/AnimationManager.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.JsNumber 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | import scala.scalajs.js.| 8 | 9 | /** 10 | * The Animation Manager is used to add, play and update Phaser Animations. 11 | * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. 12 | * @param sprite A reference to the Game Object that owns this AnimationManager. 13 | * @see https://phaser.io/docs/2.6.2/Phaser.AnimationManager.html 14 | */ 15 | @js.native 16 | @JSGlobal("Phaser.AnimationManager") 17 | class AnimationManager(sprite: Phaser.Sprite) extends js.Object { 18 | 19 | ///////////////////////////////////////////////////////////////////////////////// 20 | // Properties 21 | ///////////////////////////////////////////////////////////////////////////////// 22 | 23 | /** 24 | * The currently displayed animation, if any. 25 | */ 26 | var currentAnim: Phaser.Animation = js.native 27 | 28 | /** 29 | * The currently displayed Frame of animation, if any. 30 | * This property is only set once an Animation starts playing. Until that point it remains set as null. 31 | */ 32 | var currentFrame: Phaser.Frame = js.native 33 | 34 | /** 35 | * Gets or sets the current frame index and updates the Texture Cache for display. 36 | */ 37 | var frame: Int = js.native 38 | 39 | /** 40 | * The current animations FrameData 41 | */ 42 | def frameData: Phaser.FrameData = js.native 43 | 44 | /** 45 | * Gets or sets the current frame name and updates the Texture Cache for display. 46 | */ 47 | var frameName: String = js.native 48 | 49 | /** 50 | * The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. 51 | */ 52 | def frameTotal: Int = js.native 53 | 54 | /** 55 | * A reference to the currently running Game. 56 | */ 57 | var game: Phaser.Game = js.native 58 | 59 | /** 60 | * Set to true once animation data has been loaded. 61 | */ 62 | var isLoaded: Boolean = js.native 63 | 64 | /** 65 | * Gets the current animation name, if set. 66 | */ 67 | var name: String = js.native 68 | 69 | /** 70 | * Gets and sets the paused state of the current animation. 71 | */ 72 | var paused: Boolean = js.native 73 | 74 | /** 75 | * Should the animation data continue to update even if the Sprite.visible is set to false. 76 | */ 77 | var updateIfVisible: Boolean = js.native 78 | 79 | ///////////////////////////////////////////////////////////////////////////////// 80 | // Methods 81 | ///////////////////////////////////////////////////////////////////////////////// 82 | 83 | /** 84 | * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. 85 | * Animations added in this way are played back with the play function. 86 | * @param name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". 87 | * @param frames An array of numbers/strings that correspond to the frames to add to this animation and in 88 | * which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. 89 | * @param frameRate The speed at which the animation should play. The speed is given in frames per second. 90 | * @param loop Whether or not the animation is looped or just plays once. 91 | * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? 92 | * @return 93 | */ 94 | def add(name: String, 95 | frames: js.Array[JsNumber | String] = js.native, 96 | frameRate: Double = js.native, 97 | loop: Boolean = js.native, 98 | useNumericIndex: Boolean = js.native): Animation = js.native 99 | 100 | /** 101 | * Destroys all references this AnimationManager contains. 102 | * Iterates through the list of animations stored in this manager and calls destroy on each of them. 103 | */ 104 | def destroy(): Unit = js.native 105 | 106 | /** 107 | * Returns an animation that was previously added by name. 108 | * @param name The name of the animation to be returned, e.g. "fire". 109 | * @return The [[Animation]] instance, if found, otherwise null. 110 | */ 111 | def getAnimation(name: String): Phaser.Animation = js.native 112 | 113 | /** 114 | * Advances by the given number of frames in the current animation, taking the loop value into consideration. 115 | * @param quantity The number of frames to advance. 116 | */ 117 | def next(quantity: Int = js.native): Unit = js.native 118 | 119 | /** 120 | * Play an animation based on the given key. The animation should previously have been added via animations.add 121 | * If the requested animation is already playing this request will be ignored. 122 | * If you need to reset an already running animation do so directly on the Animation object itself. 123 | * @param name The name of the animation to be played, e.g. "fire", "walk", "jump". 124 | * @param frameRate The framerate to play the animation at. The speed is given in frames per second. 125 | * If not provided the previously set frameRate of the Animation is used. 126 | * @param loop Should the animation be looped after playback. If not provided the previously set 127 | * loop value of the Animation is used. 128 | * @param killOnComplete If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. 129 | * @return A reference to playing [[Animation]] instance. 130 | */ 131 | def play(name: String, frameRate: Double = js.native, loop: Boolean = js.native, killOnComplete: Boolean = js.native): Phaser.Animation = js.native 132 | 133 | /** 134 | * Moves backwards the given number of frames in the current animation, taking the loop value into consideration. 135 | * @param quantity The number of frames to move back. 136 | */ 137 | def previous(quantity: Int = js.native): Unit = js.native 138 | 139 | /** 140 | * Refreshes the current frame data back to the parent Sprite and also resets the texture data. 141 | */ 142 | def refreshFrame(): Unit = js.native 143 | 144 | /** 145 | * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the 146 | * current animation is stopped. 147 | * 148 | * The currentAnim property of the AnimationManager is automatically set to the animation given. 149 | * @param name The name of the animation to be stopped, e.g. "fire". If none is given the currently 150 | * running animation is stopped. 151 | * @param resetFrame When the animation is stopped should the currentFrame be set to the first frame of the 152 | * animation (true) or paused on the last frame displayed (false) 153 | */ 154 | def stop(name: String = js.native, resetFrame: Boolean = js.native): Unit = js.native 155 | 156 | /** 157 | * 158 | * @param frames An array of frames to be validated. 159 | * @param useNumericIndex Validate the frames based on their numeric index (true) or string index (false) 160 | * @return True if all given Frames are valid, otherwise false. 161 | */ 162 | def validateFrames(frames: js.Array[_], useNumericIndex: Boolean = js.native): Boolean = js.native 163 | 164 | } 165 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/ArraySet.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * ArraySet is a Set data structure (items must be unique within the set) that also maintains order. 8 | * This allows specific items to be easily added or removed from the Set. 9 | * 10 | * Item equality (and uniqueness) is determined by the behavior of Array.indexOf. 11 | * 12 | * This used primarily by the Input subsystem. 13 | * @param list The backing array: if specified the items in the list must be unique, 14 | * per Array.indexOf, and the ownership of the array should be relinquished to the ArraySet. 15 | * @see http://phaser.io/docs/2.6.2/Phaser.ArraySet.html 16 | */ 17 | @js.native 18 | @JSGlobal("Phaser.ArraySet") 19 | class ArraySet[T](var list: js.Array[T] = js.native) extends js.Object { 20 | 21 | /** 22 | * Returns the first item and resets the cursor to the start. 23 | */ 24 | var first: T = js.native 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/AudioSprite.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Audio Sprites are a combination of audio files and a JSON configuration. The JSON follows the format of that 8 | * created by https://github.com/tonistiigi/audiosprite. 9 | * @param game the reference to the current game instance. 10 | * @param key the asset key for the sound. 11 | */ 12 | @js.native 13 | @JSGlobal("Phaser.AudioSprite") 14 | class AudioSprite(var game: Phaser.Game, var key: String) extends js.Object { 15 | 16 | ///////////////////////////////////////////////////////////////////////////////// 17 | // Properties 18 | ///////////////////////////////////////////////////////////////////////////////// 19 | 20 | /** 21 | * Is a sound set to autoplay or not? 22 | */ 23 | var autoplay: Boolean = js.native 24 | 25 | /** 26 | * If a sound is set to auto play, this holds the marker key of it. 27 | */ 28 | var autoplayKey: String = js.native 29 | 30 | /** 31 | * JSON audio atlas object. 32 | */ 33 | var config: js.Any = js.native 34 | 35 | /** 36 | * An object containing the Phaser.Sound objects for the Audio Sprite. 37 | */ 38 | var sounds: js.Any = js.native 39 | 40 | ///////////////////////////////////////////////////////////////////////////////// 41 | // Methods 42 | ///////////////////////////////////////////////////////////////////////////////// 43 | 44 | /** 45 | * Get a sound with the given name. 46 | * @param marker The name of sound to get. 47 | * @return The sound instance. 48 | */ 49 | def get(marker: String): Sound = js.native 50 | 51 | /** 52 | * Play a sound with the given name. 53 | * @param marker The name of sound to play 54 | * @param volume Volume of the sound you want to play. If none is given it will use the volume given to the Sound 55 | * when it was created (which defaults to 1 if none was specified). 56 | * @return This sound instance. 57 | */ 58 | def play(marker: String, volume: Int): Sound = js.native 59 | 60 | /** 61 | * Stop a sound with the given name. 62 | * @param marker The name of sound to stop. If none is given it will stop all sounds in the audio sprite. 63 | */ 64 | def stop(marker: String): Unit = js.native 65 | 66 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/BitmapData.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.BitmapData") 8 | class BitmapData extends js.Object 9 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/BitmapText.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.dom.html.pixijs 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | 8 | /** 9 | * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. 10 | * It then generates a new Sprite object for each letter of the text, proportionally spaced out and aligned to 11 | * match the font structure. 12 | * 13 | * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability 14 | * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by 15 | * processing the font texture in an image editor, applying fills and any other effects required. 16 | * 17 | * To create multi-line text insert \r, \n or \r\n escape codes into the text string. 18 | * 19 | * If you are having performance issues due to the volume of sprites being rendered, and do not require the text to be constantly 20 | * updating, you can use BitmapText.generateTexture to create a static texture from this BitmapText. 21 | * @param game A reference to the currently running game. 22 | * @param x X coordinate to display the BitmapText object at. 23 | * @param y Y coordinate to display the BitmapText object at. 24 | * @param font The key of the BitmapText as stored in Phaser.Cache. 25 | * @param text The text that will be rendered. This can also be set later via BitmapText.text. 26 | * @param size The size the font will be rendered at in pixels. 27 | * @param align Alignment for multi-line text ('left', 'center' or 'right'), does not affect single lines of text. 28 | * @see https://phaser.io/docs/2.6.2/Phaser.BitmapText.html 29 | */ 30 | @js.native 31 | @JSGlobal("Phaser.BitmapText") 32 | class BitmapText(var game: Phaser.Game, 33 | override var x: Double, 34 | override var y: Double, 35 | val font: String, 36 | val text: String = js.native, 37 | val size: Double = js.native, 38 | val align: String = js.native) 39 | extends pixijs.DisplayObjectContainer 40 | with Phaser.Component.Core 41 | with Phaser.Component.Angle 42 | with Phaser.Component.AutoCull 43 | with Phaser.Component.Bounds 44 | with Phaser.Component.Destroy 45 | with Phaser.Component.FixedToCamera 46 | with Phaser.Component.InputEnabled 47 | with Phaser.Component.InWorld 48 | with Phaser.Component.LifeSpan 49 | with Phaser.Component.PhysicsBody 50 | with Phaser.Component.Reset { 51 | 52 | /** 53 | * The angle property is the rotation of the Game Object in degrees from its original orientation. 54 | * 55 | * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 56 | * 57 | * Values outside this range are added to or subtracted from 360 to obtain a value within the range. 58 | * For example, the statement player.angle = 450 is the same as player.angle = 90. 59 | * 60 | * If you wish to work in radians instead of degrees you can use the property rotation instead. 61 | * Working in radians is slightly faster as it doesn't have to perform any calculations. 62 | */ 63 | override var angle: Double = js.native 64 | 65 | /** 66 | * Base destroy method for generic display objects. 67 | */ 68 | override def destroy(): Unit = js.native 69 | 70 | /** 71 | * Base destroy method for generic display objects. 72 | */ 73 | override def destroy(destroyChildren: Boolean): Unit = js.native 74 | 75 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Bullet.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.JsNumber 4 | import io.scalajs.dom.html.pixijs 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSGlobal 8 | import scala.scalajs.js.| 9 | 10 | /** 11 | * Create a new Bullet object. Bullets are used by the Phaser.Weapon class, and are normal Sprites, 12 | * with a few extra properties in the data object to handle Weapon specific features. 13 | * @param game A reference to the currently running game. 14 | * @param x The x coordinate (in world space) to position the Particle at. 15 | * @param y The y coordinate (in world space) to position the Particle at. 16 | * @param key This is the image or texture used by the Particle during rendering. It can be a string which 17 | * is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. 18 | * @param frame If this Particle is using part of a sprite sheet or texture atlas you can specify the exact 19 | * frame to use by giving a string or numeric index. 20 | * @see http://phaser.io/docs/2.6.2/Phaser.Bullet.html 21 | */ 22 | @js.native 23 | @JSGlobal("Phaser.Bullet") 24 | class Bullet(game: Phaser.Game, 25 | x: Double, 26 | y: Double, 27 | key: String | Phaser.RenderTexture | Phaser.BitmapData | pixijs.Texture, 28 | frame: JsNumber | String) extends Phaser.Sprite { 29 | 30 | 31 | 32 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Button.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.{JsNumber, RawOptions} 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | import scala.scalajs.js.| 8 | 9 | /** 10 | * Create a new Button object. A Button is a special type of Sprite that is set-up to handle Pointer events automatically. 11 | * 12 | * The four states a Button responds to are: 13 | * 14 | * 'Over' - when the Pointer moves over the Button. This is also commonly known as 'hover'. 15 | * 'Out' - when the Pointer that was previously over the Button moves out of it. 16 | * 'Down' - when the Pointer is pressed down on the Button. I.e. touched on a touch enabled device or clicked with the mouse. 17 | * 'Up' - when the Pointer that was pressed down on the Button is released again. 18 | * A different texture/frame and activation sound can be specified for any of the states. 19 | * 20 | * Frames can be specified as either an integer (the frame ID) or a string (the frame name); 21 | * the same values that can be used with a Sprite constructor. 22 | * @param game Current game instance. 23 | * @param x X position of the Button. 24 | * @param y Y position of the Button. 25 | * @param key The image key (in the Game.Cache) to use as the texture for this Button. 26 | * @param callback The function to call when this Button is pressed. 27 | * @param callbackContext The context in which the callback will be called (usually 'this'). 28 | * @param overFrame The frame / frameName when the button is in the Over state. 29 | * @param outFrame The frame / frameName when the button is in the Out state. 30 | * @param downFrame The frame / frameName when the button is in the Down state. 31 | * @param upFrame The frame / frameName when the button is in the Up state. 32 | */ 33 | @js.native 34 | @JSGlobal("Phaser.Button") 35 | class Button(game: Phaser.Game, 36 | x: Double, 37 | y: Double, 38 | key: String, 39 | var callback: js.Function, 40 | var callbackContext: RawOptions, 41 | var overFrame: String | JsNumber, 42 | var outFrame: String | JsNumber, 43 | var downFrame: String | JsNumber, 44 | var upFrame: String | JsNumber) extends Phaser.Image { 45 | 46 | /** 47 | * When the Button is touched / clicked and then released you can force it to enter a state of "out" instead of "up". 48 | * This can also accept a pointer mode bitmask for more refined control. 49 | */ 50 | var forceOut: Boolean | Phaser.PointerMode = js.native 51 | 52 | /** 53 | * When true the the texture frame will not be automatically switched on up/down/over/out events. 54 | */ 55 | var freezeFrames: Boolean = js.native 56 | 57 | /** 58 | * Suppress the over event if a pointer was just released and it matches the given pointer mode bitmask. 59 | * This behavior was introduced in Phaser 2.3.1; this property is a soft-revert of the change. 60 | */ 61 | var justReleasedPreventsOver: Phaser.PointerMode = js.native 62 | 63 | /** 64 | * The Sound Marker used in conjunction with the onDownSound. 65 | */ 66 | def onDownSoundMarker: String = js.native 67 | 68 | /** 69 | * The Signal (or event) dispatched when this Button is in an Down state. 70 | */ 71 | var onInputDown: Phaser.Signal = js.native 72 | 73 | /** 74 | * The Signal (or event) dispatched when this Button is in an Out state. 75 | */ 76 | var onInputOut: Phaser.Signal = js.native 77 | 78 | /** 79 | * The Signal (or event) dispatched when this Button is in an Over state. 80 | */ 81 | var onInputOver: Phaser.Signal = js.native 82 | 83 | /** 84 | * The Signal (or event) dispatched when this Button is in an Up state. 85 | */ 86 | var onInputUp: Phaser.Signal = js.native 87 | 88 | /** 89 | * The Sound to be played when this Buttons Out state is activated. 90 | */ 91 | var onOutSound: Phaser.Sound | Phaser.AudioSprite = js.native 92 | 93 | /** 94 | * The Sound Marker used in conjunction with the onOutSound. 95 | */ 96 | def onOutSoundMarker: String = js.native 97 | 98 | /** 99 | * If true then onOver events (such as onOverSound) will only be triggered if the Pointer object causing them was the Mouse Pointer. 100 | * The frame will still be changed as applicable. 101 | */ 102 | var onOverMouseOnly: Boolean = js.native 103 | 104 | /** 105 | * The Sound to be played when this Buttons Over state is activated. 106 | */ 107 | def onOverSound: Phaser.Sound | Phaser.AudioSprite = js.native 108 | 109 | /** 110 | * The Sound Marker used in conjunction with the onOverSound. 111 | */ 112 | def onOverSoundMarker: String = js.native 113 | 114 | /** 115 | * The Sound to be played when this Buttons Up state is activated. 116 | */ 117 | def onUpSound: Phaser.Sound | Phaser.AudioSprite = js.native 118 | 119 | /** 120 | * The Sound Marker used in conjunction with the onUpSound. 121 | */ 122 | def onUpSoundMarker: String = js.native 123 | 124 | /** 125 | * A Game Object is that is pendingDestroy is flagged to have its destroy method called on the next logic update. 126 | * You can set it directly to allow you to flag an object to be destroyed on its next update. 127 | * 128 | * This is extremely useful if you wish to destroy an object from within one of its own callbacks 129 | * such as with Buttons or other Input events. 130 | */ 131 | var pendingDestroy: Boolean = js.native 132 | 133 | /** 134 | * The const physics body type of this object. 135 | */ 136 | def physicsType: Int = js.native 137 | 138 | /** 139 | * The position the Game Object was located in the previous frame. 140 | */ 141 | def previousPosition: Phaser.Point = js.native 142 | 143 | /** 144 | * The rotation the Game Object was in set to in the previous frame. Value is in radians. 145 | */ 146 | def previousRotation: Int = js.native 147 | 148 | /** 149 | * The render order ID is used internally by the renderer and Input Manager and should not be modified. 150 | * This property is mostly used internally by the renderers, but is exposed for the use of plugins. 151 | */ 152 | def renderOrderID: Int = js.native 153 | 154 | 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Cache.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Phaser has one single cache in which it stores all assets. 8 | * 9 | * The cache is split up into sections, such as images, sounds, video, json, etc. All assets are stored using 10 | * a unique string-based key as their identifier. Assets stored in different areas of the cache can have the 11 | * same key, for example 'playerWalking' could be used as the key for both a sprite sheet and an audio file, 12 | * because they are unique data types. 13 | * 14 | * The cache is automatically populated by the Phaser.Loader. When you use the loader to pull in external assets 15 | * such as images they are automatically placed into their respective cache. Most common Game Objects, such as 16 | * Sprites and Videos automatically query the cache to extract the assets they need on instantiation. 17 | * 18 | * You can access the cache from within a State via this.cache. From here you can call any public method it has, 19 | * including adding new entries to it, deleting them or querying them. 20 | * 21 | * Understand that almost without exception when you get an item from the cache it will return a reference to the 22 | * item stored in the cache, not a copy of it. Therefore if you retrieve an item and then modify it, the original 23 | * object in the cache will also be updated, even if you don't put it back into the cache again. 24 | * 25 | * By default when you change State the cache is not cleared, although there is an option to clear it should 26 | * your game require it. In a typical game set-up the cache is populated once after the main game has loaded and 27 | * then used as an asset store. 28 | * @see https://phaser.io/docs/2.6.2/Phaser.Cache.html 29 | * @author lawrence.daniels@gmail.com 30 | */ 31 | @js.native 32 | @JSGlobal("Phaser.Cache") 33 | class Cache(var game: Phaser.Game) extends js.Object 34 | 35 | @js.native 36 | @JSGlobal("Phaser.Cache") 37 | object Cache extends js.Object { 38 | val BINARY: Int = js.native 39 | val BITMAPDATA: Int = js.native 40 | val BITMAPFONT: Int = js.native 41 | val CANVAS: Int = js.native 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Camera.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. 8 | * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y 9 | * @param game Game reference to the currently running game. 10 | * @param id Not being used at the moment, will be when Phaser supports multiple camera 11 | * @param x Position of the camera on the X axis 12 | * @param y Position of the camera on the Y axis 13 | * @param width The width of the view rectangle 14 | * @param height The height of the view rectangle 15 | */ 16 | @js.native 17 | @JSGlobal("Phaser.Camera") 18 | class Camera(var game: Phaser.Game, val id: Int = 0, var x: Double, var y: Double, var width: Double, var height: Double) 19 | extends js.Object { 20 | 21 | /** 22 | * Camera view. 23 | * The view into the world we wish to render (by default the game dimensions). 24 | * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. 25 | * Sprites outside of this view are not rendered if Sprite.autoCull is set to `true`. Otherwise they are always rendered. 26 | */ 27 | val view: Rectangle = js.native 28 | 29 | /** 30 | * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. 31 | * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound 32 | * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the top-left of the world. 33 | * @return The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere. 34 | */ 35 | val bounds: Rectangle = js.native 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Canvas.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.dom.html.HTMLElement 4 | import io.scalajs.dom.html.canvas.{CanvasRenderingContext2D, HTMLCanvasElement} 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSGlobal 8 | import scala.scalajs.js.| 9 | 10 | /** 11 | * The Canvas class handles everything related to creating the canvas DOM tag that Phaser will use, 12 | * including styles, offset and aspect ratio. 13 | * @see http://phaser.io/docs/2.6.2/Phaser.Canvas.html 14 | */ 15 | @js.native 16 | @JSGlobal("Phaser.Canvas") 17 | class Canvas() extends js.Object 18 | 19 | /** 20 | * Canvas Singleton 21 | */ 22 | @js.native 23 | @JSGlobal("Phaser.Canvas") 24 | object Canvas extends js.Object { 25 | 26 | /** 27 | * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent. 28 | * If no parent is given it will be added as a child of the document.body. 29 | * @param canvas The canvas to be added to the DOM. 30 | * @param parent The DOM element to add the canvas to. 31 | * @param overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element. 32 | * @return Returns the source canvas. 33 | */ 34 | def addToDOM(canvas: HTMLCanvasElement, parent: String | HTMLElement, overflowHidden: Boolean = js.native): HTMLCanvasElement = js.native 35 | 36 | /** 37 | * Creates a `canvas` DOM element. The element is not automatically added to the document. 38 | * @param parent The object that will own the canvas that is created. 39 | * @param width The width of the canvas element. 40 | * @param height The height of the canvas element. 41 | * @param id If specified, and not the empty string, this will be set as the ID of the 42 | * canvas element. Otherwise no ID will be set. 43 | * @param skipPool If `true` the canvas will not be placed in the CanvasPool global. 44 | * @return The newly created canvas element. 45 | */ 46 | def create(parent: js.Any, 47 | width: Int = js.native, 48 | height: Int = js.native, 49 | id: String = js.native, 50 | skipPool: Boolean = js.native): HTMLCanvasElement = js.native 51 | 52 | /** 53 | * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. 54 | * @param context The context to check for smoothing on. 55 | * @return True if the given context has image smoothing enabled, otherwise false.¬ 56 | */ 57 | def getSmoothingEnabled(context: CanvasRenderingContext2D): Boolean = js.native 58 | 59 | /** 60 | * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. 61 | * @param context The context to enable or disable the image smoothing on. 62 | * @return Returns the smoothingEnabled vendor prefix, or null if not set on the context. 63 | */ 64 | def getSmoothingPrefix(context: CanvasRenderingContext2D): String = js.native 65 | 66 | /** 67 | * Removes the given canvas element from the DOM. 68 | * @param canvas The canvas to be removed from the DOM. 69 | */ 70 | def removeFromDOM(canvas: HTMLCanvasElement): Unit = js.native 71 | 72 | /** 73 | * Sets the background color behind the canvas. This changes the canvas style property. 74 | * @param canvas The canvas to set the background color on. 75 | * @param color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color. 76 | * @return the source canvas. 77 | */ 78 | def setBackgroundColor(canvas: HTMLCanvasElement, color: String): HTMLCanvasElement = js.native 79 | 80 | /** 81 | * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). 82 | * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method. 83 | * @param canvas The canvas to set image-rendering bicubic on. 84 | * @return the source canvas. 85 | */ 86 | def setImageRenderingBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement = js.native 87 | 88 | /** 89 | * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). 90 | * Note that if this doesn't given the desired result then see the setSmoothingEnabled. 91 | * @param canvas The canvas to set image-rendering crisp on. 92 | * @return the source canvas. 93 | */ 94 | def setImageRenderingCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement = js.native 95 | 96 | /** 97 | * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. 98 | * By default browsers have image smoothing enabled, which isn't always what you visually want, especially 99 | * when using pixel art in a game. Note that this sets the property on the context itself, so that any image 100 | * drawn to the context will be affected. This sets the property across all current browsers but support is 101 | * patchy on earlier browsers, especially on mobile. 102 | * @param context The context to enable or disable the image smoothing on. 103 | * @param value If set to true it will enable image smoothing, false will disable it. 104 | * @return the source context. 105 | */ 106 | def setSmoothingEnabled(context: CanvasRenderingContext2D, value: Boolean): CanvasRenderingContext2D = js.native 107 | 108 | /** 109 | * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. 110 | * @param canvas The canvas to set the touch action on. 111 | * @param value The touch action to set. Defaults to 'none'. 112 | * @return The source canvas. 113 | */ 114 | def setTouchAction(canvas: HTMLCanvasElement, value: String = js.native): HTMLCanvasElement = js.native 115 | 116 | /** 117 | * Sets the transform of the given canvas to the matrix values provided. 118 | * @param context The context to set the transform on. 119 | * @param translateX The value to translate horizontally by. 120 | * @param translateY The value to translate vertically by. 121 | * @param scaleX The value to scale horizontally by. 122 | * @param scaleY The value to scale vertically by. 123 | * @param skewX The value to skew horizontally by. 124 | * @param skewY The value to skew vertically by. 125 | * @return the source context. 126 | */ 127 | def setTransform(context: CanvasRenderingContext2D, 128 | translateX: Double, 129 | translateY: Double, 130 | scaleX: Double, 131 | scaleY: Double, 132 | skewX: Double, 133 | skewY: Double): CanvasRenderingContext2D = js.native 134 | 135 | /** 136 | * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. 137 | * @param canvas The canvas to set the touch action on. 138 | * @param value The touch action to set. Defaults to 'none'. 139 | * @return The source canvas. 140 | */ 141 | def setUserSelect(canvas: HTMLCanvasElement, value: String = js.native): HTMLCanvasElement = js.native 142 | 143 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Circle.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter 8 | * specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter 9 | * and radius properties set to 0 is created. 10 | * @param x The x coordinate of the center of the circle. 11 | * @param y The y coordinate of the center of the circle. 12 | * @param diameter The diameter of the circle. 13 | */ 14 | @js.native 15 | @JSGlobal("Phaser.Circle") 16 | class Circle(var x: Double = 0, var y: Double = 0, var diameter: Double = 0) extends js.Object { 17 | 18 | /** 19 | * The area of this Circle. 20 | */ 21 | def area: Double = js.native 22 | 23 | /** 24 | * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on 25 | * the x and y properties, but does change the diameter. Gets or sets the bottom of the circle. 26 | */ 27 | var bottom: Double = js.native 28 | 29 | /** 30 | * Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects 31 | * diameter is less than or equal to 0; otherwise false. If set to true it will reset all of the Circle objects 32 | * properties to 0. A Circle object is empty if its diameter is less than or equal to 0. Gets or sets the empty 33 | * state of the circle. 34 | */ 35 | var empty: Boolean = js.native 36 | 37 | /** 38 | * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no 39 | * effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not 40 | * affect the diameter property. 41 | */ 42 | var left: Double = js.native 43 | 44 | /** 45 | * The length of a line extending from the center of the circle to any point on the circle itself. The same as 46 | * half the diameter. Gets or sets the radius of the circle. 47 | */ 48 | var radius: Double = js.native 49 | 50 | /** 51 | * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no 52 | * effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not 53 | * affect the diameter property. Gets or sets the value of the rightmost point of the circle. 54 | */ 55 | var right: Double = js.native 56 | 57 | /** 58 | * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on 59 | * the x and y properties, but does change the diameter. Gets or sets the top of the circle. 60 | */ 61 | var top: Double = js.native 62 | 63 | /** 64 | * The const type of this object. 65 | */ 66 | def `type`: Int = js.native 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Create.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Phaser Create 8 | * @author lawrence.daniels@gmail.com 9 | */ 10 | @js.native 11 | @JSGlobal("Phaser.Create") 12 | class Create extends js.Object 13 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/CursorKeys.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Phaser Cursor Keys 8 | * @author lawrence.daniels@gmail.com 9 | */ 10 | @js.native 11 | trait CursorKeys extends js.Object { 12 | 13 | def up: Key = js.native 14 | 15 | def down: Key = js.native 16 | 17 | def left: Key = js.native 18 | 19 | def right: Key = js.native 20 | 21 | } 22 | 23 | /** 24 | * CursorKeys Singleton 25 | * @author lawrence.daniels@gmail.com 26 | */ 27 | @js.native 28 | @JSGlobal("Phaser.CursorKeys") 29 | object CursorKeys extends CursorKeys -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Device.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Created by ldaniels on 1/29/17. 8 | */ 9 | @js.native 10 | @JSGlobal("Phaser.Device") 11 | class Device extends js.Object 12 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/DeviceButton.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Created by ldaniels on 1/30/17. 8 | */ 9 | @js.native 10 | @JSGlobal("Phaser.DeviceButton") 11 | class DeviceButton extends js.Object { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Easing.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Phaser Easing 8 | * @author lawrence.daniels@gmail.com 9 | */ 10 | @js.native 11 | @JSGlobal("Phaser.Easing") 12 | class Easing extends js.Object 13 | 14 | /** 15 | * Phaser Easing Singleton 16 | * @author lawrence.daniels@gmail.com 17 | */ 18 | @js.native 19 | @JSGlobal("Phaser.Easing") 20 | object Easing extends js.Object { 21 | val Linear: Linear = js.native 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Ellipse.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Creates a Ellipse object. A curve on a plane surrounding two focal points. 8 | * @param x The X coordinate of the upper-left corner of the framing rectangle of this ellipse. 9 | * @param y The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. 10 | * @param width The overall width of this ellipse. 11 | * @param height The overall height of this ellipse. 12 | * @see http://phaser.io/docs/2.6.2/Phaser.Ellipse.html 13 | */ 14 | @js.native 15 | @JSGlobal("Phaser.Ellipse") 16 | class Ellipse(var x: Double, var y: Double, var width: Double, var height: Double) extends js.Object { 17 | 18 | /** 19 | * Returns a new Ellipse object with the same values for the x, y, width, and height properties as this Ellipse object. 20 | * @param output Optional Ellipse object. If given the values will be set into the object, otherwise a brand 21 | * new Ellipse object will be created and returned. 22 | * @return The cloned Ellipse object. 23 | */ 24 | def clone(output: Phaser.Ellipse = js.native): Phaser.Ellipse = js.native 25 | 26 | /** 27 | * Return true if the given x/y coordinates are within this Ellipse object. 28 | * @param x The X value of the coordinate to test. 29 | * @param y The Y value of the coordinate to test. 30 | * @return True if the coordinates are within this ellipse, otherwise false. 31 | */ 32 | def contains(x: Double, y: Double): Boolean = js.native 33 | 34 | /** 35 | * Copies the x, y, width and height properties from any given object to this Ellipse. 36 | * @param source The object to copy from. 37 | * @return This Ellipse object. 38 | */ 39 | def copyFrom(source: js.Any): Phaser.Ellipse = js.native 40 | 41 | /** 42 | * Copies the x, y, width and height properties from this Ellipse to any given object. 43 | * @param dest The object to copy to. 44 | * @return This dest object. 45 | */ 46 | def copyTo(dest: js.Any): js.Any = js.native 47 | 48 | /** 49 | * Returns the framing rectangle of the ellipse as a [[Phaser.Rectangle]] object. 50 | * @return The bounds of the Ellipse. 51 | */ 52 | def getBounds(): Phaser.Rectangle = js.native 53 | 54 | /** 55 | * Returns a uniformly distributed random point from anywhere within this Ellipse. 56 | * @param out A Phaser.Point, or any object with public x/y properties, that the values will be set in. 57 | * If no object is provided a new Phaser.Point object will be created. In high performance areas 58 | * avoid this by re-using an existing object. 59 | * @return An object containing the random point in its `x` and `y` properties. 60 | */ 61 | def random(out: Phaser.Point = js.native): Phaser.Point = js.native 62 | 63 | /** 64 | * Sets the members of the Ellipse to the specified values. 65 | * @param x The X coordinate of the upper-left corner of the framing rectangle of this ellipse. 66 | * @param y The Y coordinate of the upper-left corner of the framing rectangle of this ellipse. 67 | * @param width The overall width of this ellipse. 68 | * @param height The overall height of this ellipse. 69 | * @return This Ellipse object. 70 | */ 71 | def setTo(x: Double, y: Double, width: Double, height: Double): Phaser.Ellipse = js.native 72 | 73 | } 74 | 75 | /** 76 | * Ellipse Singleton 77 | */ 78 | @js.native 79 | @JSGlobal("Phaser.Ellipse") 80 | object Ellipse extends js.Object { 81 | 82 | /** 83 | * Return true if the given x/y coordinates are within the Ellipse object. 84 | * @param a The Ellipse to be checked. 85 | * @param x The X value of the coordinate to test. 86 | * @param y The Y value of the coordinate to test. 87 | * @return True if the coordinates are within this ellipse, otherwise false. 88 | */ 89 | def contains(a: Phaser.Ellipse, x: Double, y: Double): Boolean = js.native 90 | 91 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Events.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * The Events component is a collection of events fired by the parent Game Object. 8 | * 9 | * Phaser uses what are known as 'Signals' for all event handling. All of the events in 10 | * this class are signals you can subscribe to, much in the same way you'd "listen" for 11 | * an event. 12 | * 13 | * For example to tell when a Sprite has been added to a new group, you can bind a function 14 | * to the onAddedToGroup signal: 15 | * 16 | * `sprite.events.onAddedToGroup.add(yourFunction, this);` 17 | * 18 | * Where yourFunction is the function you want called when this event occurs. 19 | * 20 | * For more details about how signals work please see the Phaser.Signal class. 21 | * 22 | * The Input-related events will only be dispatched if the Sprite has had inputEnabled set to true 23 | * and the Animation-related events only apply to game objects with animations like Phaser.Sprite. 24 | * @param sprite A reference to the game object / Sprite that owns this Events object. 25 | * @see http://phaser.io/docs/2.6.2/Phaser.Events.html 26 | */ 27 | @js.native 28 | @JSGlobal("Phaser.Events") 29 | class Events(val sprite: Phaser.Sprite) extends js.Object { 30 | 31 | /** 32 | * This signal is dispatched when this Game Object is added to a new Group. 33 | * It is sent two arguments: 34 | * {any} The Game Object that was added to the Group. 35 | * {Phaser.Group} The Group it was added to. 36 | */ 37 | var onAddedToGroup: Phaser.Signal = js.native 38 | 39 | /** 40 | * This signal is dispatched if the Game Object has the AnimationManager component, 41 | * and an Animation has been stopped (via animation.stop() and the dispatchComplete argument has been set. 42 | * You can also listen to Animation.onComplete rather than via the Game Objects events. 43 | * It is sent two arguments: 44 | * {any} The Game Object that received the event. 45 | * {Phaser.Animation} The Phaser.Animation that was stopped. 46 | */ 47 | var onAnimationComplete: Phaser.Signal = js.native 48 | 49 | /** 50 | * This signal is dispatched if the Game Object has the AnimationManager component, 51 | * and an Animation has looped playback. 52 | * You can also listen to Animation.onLoop rather than via the Game Objects events. 53 | * It is sent two arguments: 54 | * {any} The Game Object that received the event. 55 | * {Phaser.Animation} The Phaser.Animation that looped. 56 | */ 57 | var onAnimationLoop: Phaser.Signal = js.native 58 | 59 | /** 60 | * This signal is dispatched if the Game Object has the AnimationManager component, 61 | * and an Animation has been played. 62 | * You can also listen to Animation.onStart rather than via the Game Objects events. 63 | * It is sent two arguments: 64 | * {any} The Game Object that received the event. 65 | * {Phaser.Animation} The Phaser.Animation that was started. 66 | */ 67 | var onAnimationStart: Phaser.Signal = js.native 68 | 69 | /** 70 | * This signal is dispatched when the Game Object is destroyed. 71 | * This happens when Sprite.destroy() is called, or Group.destroy() with destroyChildren set to true. 72 | * It is sent one argument: 73 | * {any} The Game Object that was destroyed. 74 | */ 75 | var onDestroy: Phaser.Signal = js.native 76 | 77 | /** 78 | * This signal is dispatched if the Game Object has been inputEnabled and enableDrag has been set. 79 | * It is sent when a Phaser.Pointer starts to drag the Game Object, taking into consideration the various 80 | * drag limitations that may be set. 81 | * It is sent four arguments: 82 | * {any} The Game Object that received the event. 83 | * {Phaser.Pointer} The Phaser.Pointer object that caused the event. 84 | * {number} The x coordinate that the drag started from. 85 | * {number} The y coordinate that the drag started from. 86 | */ 87 | var onDragStart: Phaser.Signal = js.native 88 | 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Frame.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * A Frame is a single frame of an animation and is part of a [[FrameData]] collection. 8 | * @param index The index of this Frame within the FrameData set it is being added to. 9 | * @param x X position of the frame within the texture image. 10 | * @param y Y position of the frame within the texture image. 11 | * @param width Width of the frame within the texture image. 12 | * @param height Height of the frame within the texture image. 13 | * @param name The name of the frame. In Texture Atlas data this is usually set to the filename. 14 | * @see https://phaser.io/docs/2.6.2/Phaser.Frame.html 15 | */ 16 | @js.native 17 | @JSGlobal("Phaser.Frame") 18 | class Frame(var index: Int, var x: Double, var y: Double, var width: Double, var height: Double, var name: String) extends js.Object { 19 | 20 | ///////////////////////////////////////////////////////////////////////////////// 21 | // Properties 22 | ///////////////////////////////////////////////////////////////////////////////// 23 | 24 | /** 25 | * The bottom of the frame (y + height). 26 | */ 27 | var bottom: Double = js.native 28 | 29 | /** 30 | * Center X position within the image to cut from. 31 | */ 32 | var centerX: Double = js.native 33 | 34 | /** 35 | * Center Y position within the image to cut from. 36 | */ 37 | var centerY: Double = js.native 38 | 39 | /** 40 | * The distance from the top left to the bottom-right of this Frame. 41 | */ 42 | var distance: Double = js.native 43 | 44 | /** 45 | * The right of the Frame (x + width). 46 | */ 47 | var right: Double = js.native 48 | 49 | /** 50 | * Rotated? (not yet implemented) 51 | */ 52 | var rotated: Boolean = js.native 53 | 54 | /** 55 | * Either 'cw' or 'ccw', rotation is always 90 degrees. 56 | */ 57 | var rotationDirection: String = js.native 58 | 59 | /** 60 | * Height of the original sprite before it was trimmed. 61 | */ 62 | var sourceSizeH: Double = js.native 63 | 64 | /** 65 | * Width of the original sprite before it was trimmed. 66 | */ 67 | var sourceSizeW: Double = js.native 68 | 69 | /** 70 | * Height of the trimmed sprite. 71 | */ 72 | var spriteSourceSizeH: Double = js.native 73 | 74 | /** 75 | * Width of the trimmed sprite. 76 | */ 77 | var spriteSourceSizeW: Double = js.native 78 | 79 | /** 80 | * X position of the trimmed sprite inside original sprite. 81 | */ 82 | var spriteSourceSizeX: Double = js.native 83 | 84 | /** 85 | * Y position of the trimmed sprite inside original sprite. 86 | */ 87 | var spriteSourceSizeY: Double = js.native 88 | 89 | /** 90 | * Was it trimmed when packed? 91 | */ 92 | var trimmed: Boolean = js.native 93 | 94 | ///////////////////////////////////////////////////////////////////////////////// 95 | // Methods 96 | ///////////////////////////////////////////////////////////////////////////////// 97 | 98 | /** 99 | * Clones this Frame into a new Phaser.Frame object and returns it. 100 | * Note that all properties are cloned, including the name, index and UUID. 101 | * @return An exact copy of this Frame object. 102 | */ 103 | override def clone(): this.type = js.native 104 | 105 | /** 106 | * Returns a Rectangle set to the dimensions of this Frame. 107 | * @param out A rectangle to copy the frame dimensions to. 108 | * @return A rectangle. 109 | */ 110 | def getRect(out: Phaser.Rectangle = js.native): Phaser.Rectangle = js.native 111 | 112 | /** 113 | * Adjusts of all the Frame properties based on the given width and height values. 114 | * @param width The new width of the Frame. 115 | * @param height The new height of the Frame. 116 | */ 117 | def resize(width: Double, height: Double): Unit = js.native 118 | 119 | /** 120 | * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. 121 | * @param trimmed If this frame was trimmed or not. 122 | * @param actualWidth The width of the frame before being trimmed. 123 | * @param actualHeight The height of the frame before being trimmed. 124 | * @param destX The destination X position of the trimmed frame for display. 125 | * @param destY The destination Y position of the trimmed frame for display. 126 | * @param destWidth The destination width of the trimmed frame for display. 127 | * @param destHeight The destination height of the trimmed frame for display. 128 | */ 129 | def setTrim(trimmed: Boolean, actualWidth: Double, actualHeight: Double, destX: Double, destY: Double, destWidth: Double, destHeight: Double): Unit = js.native 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/FrameData.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * FrameData is a container for [[Frame]] objects, which are the internal representation of animation data in Phaser. 8 | * @see https://phaser.io/docs/2.6.2/Phaser.FrameData.html 9 | */ 10 | @js.native 11 | @JSGlobal("Phaser.FrameData") 12 | class FrameData() extends js.Object { 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // Properties 16 | ///////////////////////////////////////////////////////////////////////////////// 17 | 18 | /** 19 | * The total number of frames in this FrameData set. 20 | */ 21 | def total: Int = js.native 22 | 23 | ///////////////////////////////////////////////////////////////////////////////// 24 | // Methods 25 | ///////////////////////////////////////////////////////////////////////////////// 26 | 27 | /** 28 | * Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly. 29 | * @param frame The frame to add to this FrameData set. 30 | * @return The frame that was just added. 31 | */ 32 | def addFrame(frame: Phaser.Frame): Phaser.Frame = js.native 33 | 34 | /** 35 | * Check if there is a Frame with the given name. 36 | * @param name The name of the frame you want to check. 37 | * @return True if the frame is found, otherwise false. 38 | */ 39 | def checkFrameName(name: String): Boolean = js.native 40 | 41 | /** 42 | * Makes a copy of this FrameData including copies (not references) to all of the Frames it contains. 43 | * @return A clone of this object, including clones of the Frame objects it contains. 44 | */ 45 | override def clone(): this.type = js.native 46 | 47 | /** 48 | * Destroys this FrameData collection by nulling the _frames and _frameNames arrays. 49 | */ 50 | def destroy(): Unit = js.native 51 | 52 | /** 53 | * Get a Frame by its numerical index. 54 | * @param index The index of the frame you want to get. 55 | * @return The frame, if found. 56 | */ 57 | def getFrame(index: Int): Phaser.Frame = js.native 58 | 59 | /** 60 | * Get a Frame by its frame name. 61 | * @param name The name of the frame you want to get. 62 | * @return The frame, if found. 63 | */ 64 | def getFrameByName(name: String): Phaser.Frame = js.native 65 | 66 | /** 67 | * Returns all of the Frame indexes in this FrameData set. 68 | * The frames indexes are returned in the output array, or if none is provided in a new Array object. 69 | * @param frames An Array containing the indexes of the frames to retrieve. If undefined or the array is empty then all frames in the FrameData are returned. 70 | * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? (false) 71 | * @param output If given the results will be appended to the end of this array otherwise a new array will be created. 72 | * @return An array of all Frame indexes matching the given names or IDs. 73 | */ 74 | def getFrameIndexes(frames: js.Array[Int] = js.native, useNumericIndex: Boolean = js.native, output: js.Array[Int] = js.native): js.Array[Int] = js.native 75 | 76 | /** 77 | * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. 78 | * @param start The starting frame index. 79 | * @param end The ending frame index. 80 | * @param output If given the results will be appended to the end of this array otherwise a new array will be created. 81 | * @return An array of Frames between the start and end index values, or an empty array if none were found. 82 | */ 83 | def getFrameRange(start: Int, end: Int, output: js.Array[Phaser.Frame] = js.native): js.Array[Phaser.Frame] = js.native 84 | 85 | /** 86 | * Returns all of the Frames in this FrameData set where the frame index is found in the input array. 87 | * The frames are returned in the output array, or if none is provided in a new Array object. 88 | * @param frames An Array containing the indexes of the frames to retrieve. If the array is empty 89 | * or undefined then all frames in the FrameData are returned. 90 | * @param useNumericIndex Are the given frames using numeric indexes (default) or strings? (false) 91 | * @param output If given the results will be appended to the end of this array otherwise a new array will be created. 92 | * @return An array of all [[Frame]]s in this FrameData set matching the given names or IDs. 93 | */ 94 | def getFrames(frames: js.Array[Int] = js.native, useNumericIndex: Boolean = js.native, output: js.Array[Frame] = js.native): js.Array[Frame] = js.native 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Game.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.dom.html.HTMLElement 4 | import io.scalajs.dom.html.canvas.CanvasRenderingContext2D 5 | import io.scalajs.dom.html.phaser.utils.Debug 6 | import io.scalajs.{JsNumber, RawOptions} 7 | 8 | import scala.scalajs.js 9 | import scala.scalajs.js.annotation.JSGlobal 10 | import scala.scalajs.js.| 11 | 12 | /** 13 | * This is where the magic happens. The Game object is the heart of your game, providing quick access to 14 | * common functions and handling the boot process. 15 | * @param width The width of your game in game pixels. If given as a string the value must be between 0 and 100 16 | * and will be used as the percentage width of the parent container, or the browser window if no parent is given. 17 | * @param height The height of your game in game pixels. If given as a string the value must be between 0 and 100 18 | * and will be used as the percentage height of the parent container, or the browser window if no parent is given. 19 | * @param renderer Which renderer to use: Phaser.AUTO will auto-detect, [[Phaser.WEBGL]], [[Phaser.CANVAS]] or 20 | * [[Phaser.HEADLESS]] (no rendering at all). 21 | * @param parent The DOM element into which this games canvas will be injected. Either a DOM ID (string) or the element itself. 22 | * @param state The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null. 23 | * @param transparent Use a transparent canvas background or not. 24 | * @param antialias Draw all image textures anti-aliased or not. The default is for smooth textures, but disable 25 | * if your game features pixel art. 26 | * @param physicsConfig A physics configuration object to pass to the Physics world on creation. 27 | * @see https://phaser.io/docs/2.6.2/Phaser.Game.html 28 | * @author lawrence.daniels@gmail.com 29 | */ 30 | @js.native 31 | @JSGlobal("Phaser.Game") 32 | class Game(val width: JsNumber | String = js.native, 33 | val height: JsNumber | String = js.native, 34 | val renderer: Int = js.native, 35 | val parent: String | HTMLElement = js.native, 36 | val state: State = js.native, 37 | val transparent: Boolean = js.native, 38 | val antialias: Boolean = js.native, 39 | val physicsConfig: RawOptions = js.native) 40 | extends js.Object { 41 | 42 | /** 43 | * Reference to the Phaser.GameObjectFactory. 44 | */ 45 | def add: GameObjectFactory = js.native 46 | 47 | /** 48 | * Reference to the assets cache. 49 | */ 50 | def cache: Cache = js.native 51 | 52 | /** 53 | * A handy reference to world.camera. 54 | */ 55 | def camera: Camera = js.native 56 | 57 | /** 58 | * Clear the Canvas each frame before rendering the display list. 59 | * You can set this to `false` to gain some performance if your game always contains a background that completely fills the display. 60 | */ 61 | var clearBeforeRender: Boolean = js.native 62 | 63 | /** 64 | * The Phaser.Game configuration object. 65 | */ 66 | def config: GameConfigObject = js.native 67 | 68 | /** 69 | * A handy reference to renderer.context (only set for CANVAS games, not WebGL) 70 | */ 71 | def context: CanvasRenderingContext2D = js.native 72 | 73 | /** 74 | * The Asset Generator. 75 | */ 76 | def create: Create = js.native 77 | 78 | /** 79 | * A set of useful debug utilities. 80 | */ 81 | def debug: Debug = js.native 82 | 83 | /** 84 | * Contains device information and capabilities. 85 | */ 86 | def device: Device = js.native 87 | 88 | /** 89 | * Should the game loop force a logic update, regardless of the delta timer? Set to true if you know you need this. 90 | * You can toggle it on the fly. 91 | */ 92 | def forceSingleUpdate: Boolean = js.native 93 | 94 | /** 95 | * If the game is struggling to maintain the desired FPS, this signal will be dispatched. 96 | * The desired/chosen FPS should probably be closer to the Phaser.Time#suggestedFps value. 97 | */ 98 | def fpsProblemNotifier: Signal = js.native 99 | 100 | /** 101 | * Phaser Game ID (for when Pixi supports multiple instances). 102 | */ 103 | def id: Int = js.native 104 | 105 | /** 106 | * Reference to the input manager 107 | */ 108 | def input: Input = js.native 109 | 110 | /** 111 | * Whether the game engine is booted, aka available. 112 | */ 113 | def isBooted: Boolean = js.native 114 | 115 | /** 116 | * Is game running or paused? 117 | */ 118 | def isRunning: Boolean = js.native 119 | 120 | /** 121 | * Reference to the assets loader. 122 | */ 123 | def load: Loader = js.native 124 | 125 | /** 126 | * If false Phaser will automatically render the display list every update. If true the render loop will be skipped. 127 | * You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain 128 | * types of game or application. 129 | * 130 | * Please note that if you don't render the display list then none of the game object transforms will be updated, 131 | * so use this value carefully. 132 | */ 133 | def lockRender: Boolean = js.native 134 | 135 | /** 136 | * 137 | * @return 138 | */ 139 | def make: GameObjectCreator = js.native 140 | 141 | /** 142 | * 143 | */ 144 | def physics: Physics = js.native 145 | 146 | def rnd: RandomDataGenerator = js.native 147 | 148 | def time: Time = js.native 149 | 150 | def world: World = js.native 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/GameConfigObject.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | 5 | 6 | /** 7 | * Game Config Object 8 | * @author lawrence.daniels@gmail.com 9 | */ 10 | 11 | class GameConfigObject extends js.Object 12 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/GameObjectCreator.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.RawOptions 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | 8 | /** 9 | * The GameObjectCreator is a quick way to create common game objects without adding them to the game world. 10 | * The object creator can be accessed with `game.make`. 11 | * @see https://phaser.io/docs/2.6.2/Phaser.GameObjectCreator.html 12 | * @author lawrence.daniels@gmail.com 13 | */ 14 | @js.native 15 | @JSGlobal("Phaser.GameObjectCreator") 16 | class GameObjectCreator(var game: Phaser.Game) extends js.Object { 17 | 18 | ///////////////////////////////////////////////////////////////////////////////// 19 | // Properties 20 | ///////////////////////////////////////////////////////////////////////////////// 21 | 22 | /** 23 | * A reference to the game world 24 | */ 25 | def world: Phaser.World = js.native 26 | 27 | ///////////////////////////////////////////////////////////////////////////////// 28 | // Methods 29 | ///////////////////////////////////////////////////////////////////////////////// 30 | 31 | /** 32 | * Creates a new Sound object. 33 | * @param key The Game.cache key of the sound that this object will use. 34 | * @param volume The volume at which the sound will be played. 35 | * @param loop Whether or not the sound will loop. 36 | * @param connect Controls if the created Sound object will connect to the master gainNode of the SoundManager 37 | * when running under WebAudio. 38 | * @return The newly created text object. 39 | */ 40 | def audio(key: String, volume: Double = js.native, loop: Boolean = js.native, connect: Boolean = js.native): Phaser.Sound = js.native 41 | 42 | /** 43 | * Creates a new AudioSprite object. 44 | * @param key The Game.cache key of the sound that this object will use. 45 | * @return The newly created AudioSprite object. 46 | */ 47 | def audioSprite(key: String): Phaser.AudioSprite = js.native 48 | 49 | /** 50 | * Create a BitmpaData object. 51 | * A BitmapData object can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites. 52 | * @param width The width of the BitmapData in pixels. 53 | * @param height The height of the BitmapData in pixels. 54 | * @param key Asset key for the BitmapData when stored in the Cache (see addToCache parameter). 55 | * @param addToCache Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key) 56 | * @return The newly created [[Phaser.BitmapData]] object. 57 | */ 58 | def bitmapData(width: Double = js.native, height: Double = js.native, key: String = js.native, addToCache: Boolean = js.native): Phaser.BitmapData = js.native 59 | 60 | /** 61 | * Create a new BitmapText object. 62 | * BitmapText objects work by taking a texture file and an XML file that describes the font structure. 63 | * It then generates a new Sprite object for each letter of the text, proportionally spaced out and aligned to 64 | * match the font structure. 65 | * 66 | * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability 67 | * to use Web Fonts. However you trade this flexibility for pure rendering speed. You can also create visually compelling BitmapTexts by 68 | * processing the font texture in an image editor first, applying fills and any other effects required. 69 | * To create multi-line text insert \r, \n or \r\n escape codes into the text string. 70 | * @param x X-coordinate to display the BitmapText object at. 71 | * @param y Y-coordinate to display the BitmapText object at. 72 | * @param font The key of the BitmapText as stored in Phaser.Cache. 73 | * @param text The text that will be rendered. This can also be set later via BitmapText.text. 74 | * @param size The size the font will be rendered at in pixels. 75 | * @param align The alignment of multi-line text. Has no effect if there is only one line of text. 76 | * @return The newly created bitmapText object. 77 | */ 78 | def bitmapText(x: Double, y: Double, font: String, text: String, size: Double, align: String): Phaser.BitmapData = js.native 79 | 80 | /** 81 | * Creates a new Text object. 82 | * @param x X-position of the new text object. 83 | * @param y Y-position of the new text object. 84 | * @param text The actual text that will be written. 85 | * @param style The style object containing style attributes like font, font size , etc. 86 | * @return The newly created [[Phaser.BitmapText text object]]. 87 | */ 88 | def text(x: Double, y: Double, text: String, style: RawOptions): Phaser.Text = js.native 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/GameObjectFactory.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.dom.html.pixijs.DisplayObject 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | 8 | /** 9 | * A reference to the GameObjectFactory which can be used to add new objects to the World. 10 | * @param game the running [[Game]]. 11 | */ 12 | @js.native 13 | @JSGlobal("Phaser.GameObjectFactory") 14 | class GameObjectFactory(var game: Game = js.native) extends js.Object { 15 | 16 | ///////////////////////////////////////////////////////////////////////////////// 17 | // Properties 18 | ///////////////////////////////////////////////////////////////////////////////// 19 | 20 | /** 21 | * A reference to the game world. 22 | */ 23 | var world: World = js.native 24 | 25 | ///////////////////////////////////////////////////////////////////////////////// 26 | // Methods 27 | ///////////////////////////////////////////////////////////////////////////////// 28 | 29 | def tween(aliens: DisplayObject): Tween = js.native 30 | 31 | def text(x: Double = 0, 32 | y: Double = 0, 33 | text: String = "", 34 | style: js.Dictionary[_] = null, 35 | group: Group[_] = null): Text = js.native 36 | 37 | def sprite(x: Int = 0, y: Int = 0, key: String = null, frame: Any = null, group: Group[_] = null): Sprite = js.native 38 | 39 | def group(parent: Any = null, 40 | name: String = null, 41 | addToStage: Boolean = false, 42 | enableBody: Boolean = false, 43 | physicsBodyType: Int = 0): Group[Sprite] = js.native 44 | 45 | def tileSprite(x: Int, 46 | y: Int, 47 | width: Int, 48 | height: Int, 49 | key: String, 50 | frame: Any = null, 51 | group: Group[_] = null): TileSprite = js.native 52 | } 53 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/GameState.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | /** 4 | * Phaser: Game State 5 | * @version 2.6.2 6 | * @author lawrence.daniels@gmail.com 7 | */ 8 | trait GameState { 9 | 10 | def preload(): Unit 11 | 12 | def create(): Unit 13 | 14 | def update(): Unit 15 | 16 | def render(): Unit 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Gamepad.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.RawOptions 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.{JSGlobal, JSName, ScalaJSDefined} 7 | 8 | /** 9 | * The Gamepad class handles gamepad input and dispatches gamepad events. 10 | * 11 | * Remember to call gamepad.start(). 12 | * 13 | * HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE! 14 | * At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it 15 | * via prefs flags (about:config, search gamepad). The browsers map the same controllers differently. 16 | * This class has constants for Windows 7 Chrome mapping of XBOX 360 controller. 17 | * @see http://phaser.io/docs/2.6.2/Phaser.Gamepad.html 18 | */ 19 | @js.native 20 | @JSGlobal("Phaser.Gamepad") 21 | class Gamepad(var game: Phaser.Game) extends js.Object { 22 | 23 | ///////////////////////////////////////////////////////////////////////////////// 24 | // Properties 25 | ///////////////////////////////////////////////////////////////////////////////// 26 | 27 | /** 28 | * If the gamepad input is active or not - if not active it should not be updated from Input.js 29 | */ 30 | def active: Boolean = js.native 31 | 32 | /** 33 | * The context under which the callbacks are run. 34 | */ 35 | var callbackContext: js.Object = js.native 36 | 37 | /** 38 | * Gamepad input will only be processed if enabled (default: true). 39 | */ 40 | var enabled: Boolean = js.native 41 | 42 | /** 43 | * This callback is invoked every time any gamepad axis is changed. 44 | */ 45 | var onAxisCallback: js.Function = js.native 46 | 47 | /** 48 | * This callback is invoked every time any gamepad is disconnected 49 | */ 50 | var onConnectCallback: js.Function = js.native 51 | 52 | /** 53 | * This callback is invoked every time any gamepad button is pressed down. 54 | */ 55 | var onDownCallback: js.Function = js.native 56 | 57 | /** 58 | * This callback is invoked every time any gamepad button is changed to a value where value > 0 and value < 1. 59 | */ 60 | var onFloatCallback: js.Function = js.native 61 | 62 | /** 63 | * This callback is invoked every time any gamepad button is released. 64 | */ 65 | var onUpCallback: js.Function = js.native 66 | 67 | /** 68 | * Gamepad #1 69 | */ 70 | def pad1: Phaser.SinglePad = js.native 71 | 72 | /** 73 | * Gamepad #2 74 | */ 75 | def pad2: Phaser.SinglePad = js.native 76 | 77 | /** 78 | * Gamepad #3 79 | */ 80 | def pad3: Phaser.SinglePad = js.native 81 | 82 | /** 83 | * Gamepad #4 84 | */ 85 | def pad4: Phaser.SinglePad = js.native 86 | 87 | /** 88 | * How many live gamepads are currently connected. 89 | */ 90 | def padsConnected: Int = js.native 91 | 92 | /** 93 | * Whether or not gamepads are supported in current browser. 94 | */ 95 | def supported: Boolean = js.native 96 | 97 | ///////////////////////////////////////////////////////////////////////////////// 98 | // Methods 99 | ///////////////////////////////////////////////////////////////////////////////// 100 | 101 | /** 102 | * Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button 103 | * up/axis change/float value buttons. 104 | * @param context The context under which the callbacks are run. 105 | * @param callbacks Object that takes six different callback methods: 106 | * onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback, 107 | * onAxisCallback, onFloatCallback 108 | */ 109 | def addCallbacks(context: RawOptions, callbacks: Callbacks): Unit = js.native 110 | 111 | /** 112 | * Destroys this object and the associated event listeners. 113 | */ 114 | def destroy(): Unit = js.native 115 | 116 | /** 117 | * Returns true if the button is currently pressed down, on ANY gamepad. 118 | * @param buttonCode The buttonCode of the button to check for. 119 | * @return True if a button is currently down. 120 | */ 121 | def isDown(buttonCode: ButtonCode): Boolean = js.native 122 | 123 | /** 124 | * Returns the "just released" state of a button from ANY gamepad connected. 125 | * Just released is considered as being true if the button was released within 126 | * the duration given (default 250ms). 127 | * @param buttonCode The buttonCode of the button to check for. 128 | * @param duration The duration below which the button is considered as being just released. 129 | * @return True if the button is just released otherwise false. 130 | */ 131 | def justPressed(buttonCode: ButtonCode, duration: Double = js.native): Boolean = js.native 132 | 133 | /** 134 | * Reset all buttons/axes of all gamepads 135 | */ 136 | def reset(): Unit = js.native 137 | 138 | /** 139 | * Sets the deadZone variable for all four gamepads 140 | */ 141 | def setDeadZones(): Unit = js.native 142 | 143 | /** 144 | * Starts the Gamepad event handling. 145 | * This MUST be called manually before Phaser will start polling the Gamepad API. 146 | */ 147 | def start(): Unit = js.native 148 | 149 | /** 150 | * Stops the Gamepad event handling. 151 | */ 152 | def stop(): Unit = js.native 153 | 154 | } 155 | 156 | /** 157 | * Callbacks Object 158 | * @param onConnectCallback 159 | * @param onDisconnectCallback 160 | * @param onDownCallback 161 | * @param onUpCallback 162 | * @param onAxisCallback 163 | * @param onFloatCallback 164 | */ 165 | 166 | class Callbacks(var onConnectCallback: js.UndefOr[js.Function] = js.undefined, 167 | var onDisconnectCallback: js.UndefOr[js.Function] = js.undefined, 168 | var onDownCallback: js.UndefOr[js.Function] = js.undefined, 169 | var onUpCallback: js.UndefOr[js.Function] = js.undefined, 170 | var onAxisCallback: js.UndefOr[js.Function] = js.undefined, 171 | var onFloatCallback: js.UndefOr[js.Function] = js.undefined) extends js.Object -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Graphics.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.dom.html.pixijs 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | 8 | /** 9 | * A Graphics object is a way to draw primitives to your game. Primitives include forms of geometry, such as Rectangles, 10 | * Circles and Polygons. They also include lines, arcs and curves. When you initially create a Graphics object it will 11 | * be empty. To 'draw' to it you first specify a lineStyle or fillStyle (or both), and then draw a shape. 12 | * @param game Current game instance. 13 | * @param x X-position of the new graphics object. 14 | * @param y Y-position of the new graphics object. 15 | * @see http://phaser.io/docs/2.6.2/Phaser.Graphics.html 16 | */ 17 | @js.native 18 | @JSGlobal("Phaser.Graphics") 19 | class Graphics(var game: Phaser.Game, 20 | override var x: Double, 21 | override var y: Double) 22 | extends pixijs.Graphics 23 | with Phaser.Component.Core 24 | with Phaser.Component.Angle 25 | with Phaser.Component.AutoCull 26 | with Phaser.Component.Bounds 27 | with Phaser.Component.Destroy 28 | with Phaser.Component.FixedToCamera 29 | with Phaser.Component.InputEnabled 30 | with Phaser.Component.InWorld 31 | with Phaser.Component.LifeSpan 32 | with Phaser.Component.PhysicsBody 33 | with Phaser.Component.Reset { 34 | 35 | /** 36 | * The angle property is the rotation of the Game Object in degrees from its original orientation. 37 | * 38 | * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 39 | * 40 | * Values outside this range are added to or subtracted from 360 to obtain a value within the range. 41 | * For example, the statement player.angle = 450 is the same as player.angle = 90. 42 | * 43 | * If you wish to work in radians instead of degrees you can use the property rotation instead. 44 | * Working in radians is slightly faster as it doesn't have to perform any calculations. 45 | */ 46 | override var angle: Double = js.native 47 | 48 | /** 49 | * Base destroy method for generic display objects. 50 | */ 51 | override def destroy(): Unit = js.native 52 | 53 | /** 54 | * Base destroy method for generic display objects. 55 | */ 56 | override def destroy(destroyChildren: Boolean): Unit = js.native 57 | 58 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Image.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.JsNumber 4 | import io.scalajs.dom.html.pixijs 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSGlobal 8 | import scala.scalajs.js.| 9 | 10 | /** 11 | * An Image is a light-weight object you can use to display anything that doesn't need physics or animation. 12 | * It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple 13 | * buttons and other non-Sprite graphics. 14 | * @param game A reference to the currently running game. 15 | * @param x The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in. 16 | * @param y The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in. 17 | * @param key The texture used by the Image during rendering. It can be a string which is a reference to the Cache 18 | * entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture. 19 | * @param frame If this Image is using part of a sprite sheet or texture atlas you can specify the exact frame to use 20 | * by giving a string or numeric index. 21 | * @see http://phaser.io/docs/2.6.2/Phaser.Image.html 22 | */ 23 | @js.native 24 | @JSGlobal("Phaser.Image") 25 | class Image(var game: Phaser.Game, 26 | override var x: Double, 27 | override var y: Double, 28 | var key: String | Phaser.RenderTexture | Phaser.BitmapData | pixijs.Texture, 29 | var frame: String | JsNumber) 30 | extends pixijs.Sprite 31 | with Phaser.Component.Core 32 | with Phaser.Component.Angle 33 | with Phaser.Component.Animation 34 | with Phaser.Component.AutoCull 35 | with Phaser.Component.Bounds 36 | with Phaser.Component.BringToTop 37 | with Phaser.Component.Crop 38 | with Phaser.Component.Destroy 39 | with Phaser.Component.FixedToCamera 40 | with Phaser.Component.InputEnabled 41 | with Phaser.Component.LifeSpan 42 | with Phaser.Component.LoadTexture 43 | with Phaser.Component.Overlap 44 | with Phaser.Component.Reset 45 | with Phaser.Component.ScaleMinMax 46 | with Phaser.Component.Smoothed { 47 | 48 | protected def this() = this(js.native, js.native, js.native, js.native, js.native) 49 | 50 | /** 51 | * The angle property is the rotation of the Game Object in degrees from its original orientation. 52 | * 53 | * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 54 | * 55 | * Values outside this range are added to or subtracted from 360 to obtain a value within the range. 56 | * For example, the statement player.angle = 450 is the same as player.angle = 90. 57 | * 58 | * If you wish to work in radians instead of degrees you can use the property rotation instead. 59 | * Working in radians is slightly faster as it doesn't have to perform any calculations. 60 | */ 61 | override var angle: Double = js.native 62 | 63 | /** 64 | * Base destroy method for generic display objects. 65 | */ 66 | override def destroy(): Unit = js.native 67 | 68 | /** 69 | * Base destroy method for generic display objects. 70 | */ 71 | override def destroy(destroyChildren: Boolean): Unit = js.native 72 | 73 | /** 74 | * The const type of this object. 75 | */ 76 | def `type`: Int = js.native 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Input.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Phaser.Input is the Input Manager for all types of Input across Phaser, 8 | * including mouse, keyboard, touch and MSPointer. 9 | * The Input manager is updated automatically by the core game loop. 10 | * @param game Current game instance. 11 | * @see http://phaser.io/docs/2.6.2/Phaser.Input.html 12 | */ 13 | @js.native 14 | @JSGlobal("Phaser.Input") 15 | class Input(var game: Phaser.Game) extends js.Object { 16 | 17 | /** 18 | * The most recently active Pointer object. 19 | * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse. 20 | */ 21 | var activePointer: Phaser.Pointer = js.native 22 | 23 | /** 24 | * A Circle object centered on the x/y screen coordinates of the Input. 25 | * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. 26 | */ 27 | var circle: Phaser.Circle = js.native 28 | 29 | /** 30 | * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click. 31 | * default: 300 32 | */ 33 | var doubleTapRate: Double = js.native 34 | 35 | /** 36 | * When enabled, input (eg. Keyboard, Mouse, Touch) will be processed - as long as the 37 | * individual sources are enabled themselves. 38 | * 39 | * When not enabled, all input sources are ignored. To disable just one type of input; 40 | * for example, the Mouse, use input.mouse.enabled = false. 41 | */ 42 | var enabled: Boolean = js.native 43 | 44 | /** 45 | * 46 | */ 47 | var gamepad : Phaser.Gamepad = js.native 48 | 49 | /** 50 | * 51 | */ 52 | var keyboard: Keyboard = js.native 53 | 54 | /** 55 | * 56 | */ 57 | var onTap: Signal = js.native 58 | 59 | } 60 | 61 | @js.native 62 | @JSGlobal("Phaser.Input") 63 | object Input extends js.Object { 64 | 65 | /** 66 | * The maximum number of pointers that can be added. This excludes the mouse pointer. 67 | */ 68 | var MAX_POINTERS: Int = js.native 69 | 70 | /** 71 | * 72 | */ 73 | var MOUSE_OVERRIDES_TOUCH: Int = js.native 74 | 75 | /** 76 | * 77 | */ 78 | var MOUSE_TOUCH_COMBINE: Int = js.native 79 | 80 | 81 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Key.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js.annotation.JSGlobal 4 | import scala.scalajs.js 5 | 6 | @js.native 7 | @JSGlobal("Phaser.Key") 8 | class Key extends js.Object { 9 | def isDown: Boolean = js.native 10 | } 11 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Keyboard.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | trait Keyboard extends js.Object { 8 | 9 | val SPACEBAR: Int = js.native 10 | 11 | def addKey(code: Int): Key = js.native 12 | 13 | def createCursorKeys(): CursorKeys = js.native 14 | 15 | } 16 | 17 | @js.native 18 | @JSGlobal("Phaser.Keyboard") 19 | object Keyboard extends Keyboard -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Line.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Creates a new Line object with a start and an end point. 8 | * @param x1 The x coordinate of the start of the line. 9 | * @param y1 The y coordinate of the start of the line. 10 | * @param x2 The x coordinate of the end of the line. 11 | * @param y2 The y coordinate of the end of the line. 12 | */ 13 | @js.native 14 | @JSGlobal("Phaser.Line") 15 | class Line(var x1: Double, var y1: Double, var x2: Double, var y2: Double) extends js.Object 16 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Linear.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait Linear extends js.Object { 7 | val None: js.Function1[_, _] = js.native 8 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Loader.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait Loader extends js.Object { 7 | 8 | def image(key: String, url: String): Unit = js.native 9 | 10 | def spritesheet(key: String, 11 | url: String, 12 | frameWidth: Int, 13 | frameHeight: Int, 14 | frameMax: Int = -1, 15 | margin: Int = 0, 16 | spacing: Int = 0): Unit = js.native 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Phaser.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html 2 | package phaser 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.{JSGlobal, JSName} 6 | 7 | /** 8 | * phaser - A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers. 9 | * @version 2.6.2 10 | * @see [[https://www.npmjs.com/package/phaser]] 11 | * @author lawrence.daniels@gmail.com 12 | */ 13 | @js.native 14 | @JSGlobal("Phaser") 15 | object Phaser extends js.Object { 16 | 17 | ///////////////////////////////////////////////////////////////////////////////// 18 | // Constants 19 | ///////////////////////////////////////////////////////////////////////////////// 20 | 21 | val AUTO: Int = js.native 22 | val CANVAS: Int = js.native 23 | val HEADLESS: Int = js.native 24 | val VIDEO: Int = js.native 25 | val WEBGL: Int = js.native 26 | 27 | val ANGLE_UP: Int = js.native 28 | 29 | // Alignment Constants 30 | 31 | val BOTTOM_LEFT: Int = js.native 32 | val BOTTOM_CENTER: Int = js.native 33 | val BOTTOM_RIGHT: Int = js.native 34 | val CENTER: Int = js.native 35 | val LEFT_BOTTOM: Int = js.native 36 | val LEFT_CENTER: Int = js.native 37 | val LEFT_TOP: Int = js.native 38 | val RIGHT_BOTTOM: Int = js.native 39 | val RIGHT_CENTER: Int = js.native 40 | val RIGHT_TOP: Int = js.native 41 | val TOP_CENTER: Int = js.native 42 | val TOP_LEFT: Int = js.native 43 | val TOP_RIGHT: Int = js.native 44 | 45 | // Entity Type Constants 46 | 47 | val SPRITE: js.Any = js.native 48 | val TEXT: js.Any = js.native 49 | 50 | // Version Constants 51 | 52 | val VERSION: String = js.native 53 | 54 | ///////////////////////////////////////////////////////////////////////////////// 55 | // Class References 56 | ///////////////////////////////////////////////////////////////////////////////// 57 | 58 | type Animation = phaser.Animation 59 | type AnimationManager = phaser.AnimationManager 60 | type ArraySet[T] = phaser.ArraySet[T] 61 | type AudioSprite = phaser.AudioSprite 62 | type BitmapData = phaser.BitmapData 63 | type BitmapText = phaser.BitmapText 64 | type Bullet = phaser.Bullet 65 | type Button = phaser.Button 66 | type Cache = phaser.Cache 67 | type Camera = phaser.Camera 68 | type Canvas = phaser.Canvas 69 | type Circle = phaser.Circle 70 | type Create = phaser.Create 71 | type CursorKeys = phaser.CursorKeys 72 | type Device = phaser.Device 73 | type DeviceButton = phaser.DeviceButton 74 | type Easing = phaser.Easing 75 | type Ellipse = phaser.Ellipse 76 | type Events = phaser.Events 77 | type Frame = phaser.Frame 78 | type FrameData = phaser.FrameData 79 | type Game = phaser.Game 80 | type Gamepad = phaser.Gamepad 81 | type GameObjectCreator = phaser.GameObjectCreator 82 | type GameObjectFactory = phaser.GameObjectFactory 83 | type Graphics = phaser.Graphics 84 | type Group[T] = phaser.Group[T] 85 | type Image = phaser.Image 86 | type Input = phaser.Input 87 | type InputHandler = phaser.InputHandler 88 | type Keyboard = phaser.Keyboard 89 | type Line = phaser.Line 90 | type Math = phaser.Math 91 | type Plugin = phaser.Plugin 92 | type PluginManager = phaser.PluginManager 93 | type Point = phaser.Point 94 | type Pointer = phaser.Pointer 95 | type PointerMode = phaser.PointerMode 96 | type Polygon = phaser.Polygon 97 | type QuadTree = phaser.QuadTree 98 | type Rectangle = phaser.Rectangle 99 | type RenderTexture = phaser.RenderTexture 100 | type RoundedRectangle = phaser.RoundedRectangle 101 | type SinglePad = phaser.SinglePad 102 | type Signal = phaser.Signal 103 | type SignalBinding = phaser.SignalBinding 104 | type Sound = phaser.Sound 105 | type SoundManager = phaser.SoundManager 106 | type Sprite = phaser.Sprite 107 | type State = phaser.State 108 | type Text = phaser.Text 109 | type Texture = phaser.Texture 110 | type Tilemap = phaser.Tilemap 111 | type TilemapLayer = phaser.TilemapLayer 112 | type TileSprite = phaser.TileSprite 113 | type Time = phaser.Time 114 | type Timer = phaser.Timer 115 | type TimerEvent = phaser.TimerEvent 116 | type Tween = phaser.Tween 117 | type Video = phaser.Video 118 | type Weapon = phaser.Weapon 119 | type World = phaser.World 120 | 121 | /** 122 | * Phaser.Component class references 123 | */ 124 | @js.native 125 | @JSName("Component") 126 | object Component extends js.Object { 127 | 128 | type Angle = phaser.component.Angle 129 | type Animation = phaser.component.Animation 130 | type AutoCull = phaser.component.AutoCull 131 | type Bounds = phaser.component.Bounds 132 | type BringToTop = phaser.component.BringToTop 133 | type Core = phaser.component.Core 134 | type Crop = phaser.component.Crop 135 | type Delta = phaser.component.Delta 136 | type Destroy = phaser.component.Destroy 137 | type FixedToCamera = phaser.component.FixedToCamera 138 | type Health = phaser.component.Health 139 | type InCamera = phaser.component.InCamera 140 | type InputEnabled = phaser.component.InputEnabled 141 | type InWorld = phaser.component.InWorld 142 | type LifeSpan = phaser.component.LifeSpan 143 | type LoadTexture = phaser.component.LoadTexture 144 | type Overlap = phaser.component.Overlap 145 | type PhysicsBody = phaser.component.PhysicsBody 146 | type Reset = phaser.component.Reset 147 | type ScaleMinMax = phaser.component.ScaleMinMax 148 | type Smoothed = phaser.component.Smoothed 149 | 150 | } 151 | 152 | /** 153 | * Phaser.Utils class references 154 | */ 155 | @js.native 156 | @JSName("Physics") 157 | object Physics extends js.Object { 158 | 159 | type Arcade = phaser.physics.Arcade 160 | type Box2D = phaser.physics.Box2D 161 | type Chipmunk = phaser.physics.Chipmunk 162 | type Matter = phaser.physics.Matter 163 | type Ninja = phaser.physics.Ninja 164 | type P2 = phaser.physics.P2 165 | 166 | @js.native 167 | @JSName("Arcade") 168 | object Arcade extends js.Object { 169 | 170 | type Body = phaser.physics.arcade.Body 171 | 172 | } 173 | 174 | @js.native 175 | @JSName("Ninja") 176 | object Ninja extends js.Object { 177 | 178 | type AABB = phaser.physics.ninja.AABB 179 | type Body = phaser.physics.ninja.Body 180 | 181 | } 182 | 183 | @js.native 184 | @JSName("P2") 185 | object P2 extends js.Object { 186 | 187 | type Material = phaser.physics.p2.Material 188 | 189 | } 190 | 191 | } 192 | 193 | /** 194 | * Phaser.Utils class references 195 | */ 196 | @js.native 197 | @JSName("Utils") 198 | object Utils extends js.Object { 199 | 200 | type ArrayUtils = phaser.utils.ArrayUtils 201 | type Debug = phaser.utils.Debug 202 | type Utils = phaser.utils.Utils 203 | 204 | } 205 | 206 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Plugin.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * This is a base Plugin template to use for any Phaser plugin development. 8 | * @see http://phaser.io/docs/2.6.2/Phaser.Plugin.html 9 | */ 10 | @js.native 11 | @JSGlobal("Phaser.Plugin") 12 | class Plugin(var game: Phaser.Game, val parent: Phaser.PluginManager) extends js.Object { 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // Properties 16 | ///////////////////////////////////////////////////////////////////////////////// 17 | 18 | /** 19 | * A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. 20 | */ 21 | var active: Boolean = js.native 22 | 23 | /** 24 | * A flag to indicate if this plugin has a postRender method. 25 | */ 26 | var hasPostRender: Boolean = js.native 27 | 28 | /** 29 | * A flag to indicate if this plugin has a postUpdate method. 30 | */ 31 | var hasPostUpdate: Boolean = js.native 32 | 33 | /** 34 | * A flag to indicate if this plugin has a preUpdate method. 35 | */ 36 | var hasPreUpdate: Boolean = js.native 37 | 38 | /** 39 | * A flag to indicate if this plugin has a render method. 40 | */ 41 | var hasRender: Boolean = js.native 42 | 43 | /** 44 | * A flag to indicate if this plugin has an update method. 45 | */ 46 | var hasUpdate: Boolean = js.native 47 | 48 | /** 49 | * A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. 50 | */ 51 | var visible: Boolean = js.native 52 | 53 | ///////////////////////////////////////////////////////////////////////////////// 54 | // Methods 55 | ///////////////////////////////////////////////////////////////////////////////// 56 | 57 | /** 58 | * Clear down this Plugin and null out references 59 | */ 60 | def destroy(): Unit = js.native 61 | 62 | /** 63 | * Post-render is called after the Game Renderer and State.render have run. 64 | * It is only called if visible is set to true. 65 | */ 66 | def postRender(): Unit = js.native 67 | 68 | /** 69 | * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). 70 | * It is only called if active is set to true. 71 | */ 72 | def preUpdate(): Unit = js.native 73 | 74 | /** 75 | * Render is called right after the Game Renderer completes, but before the State.render. 76 | * It is only called if visible is set to true. 77 | */ 78 | def render(): Unit = js.native 79 | 80 | /** 81 | * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. 82 | * It is only called if active is set to true. 83 | */ 84 | def update(): Unit = js.native 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/PluginManager.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins. 8 | * @param game A reference to the currently running game. 9 | * @see http://phaser.io/docs/2.6.2/Phaser.PluginManager.html 10 | */ 11 | @js.native 12 | @JSGlobal("Phaser.PluginManager") 13 | class PluginManager(var game: Phaser.Game) extends js.Object { 14 | 15 | ///////////////////////////////////////////////////////////////////////////////// 16 | // Properties 17 | ///////////////////////////////////////////////////////////////////////////////// 18 | 19 | /** 20 | * An array of all the plugins being managed by this PluginManager. 21 | */ 22 | def plugins: js.Array[Phaser.Plugin] = js.native 23 | 24 | ///////////////////////////////////////////////////////////////////////////////// 25 | // Methods 26 | ///////////////////////////////////////////////////////////////////////////////// 27 | 28 | /** 29 | * Add a new Plugin into the PluginManager. 30 | * The Plugin must have 2 properties: game and parent. Plugin.game is set to the game reference the 31 | * PluginManager uses, and parent is set to the PluginManager. 32 | * @param plugin The [[Plugin]] to add into the PluginManager. This can be a function or an existing object. 33 | * @param parameter Additional arguments that will be passed to the Plugin.init method. 34 | * @return The [[Plugin]] that was added to the manager. 35 | */ 36 | def add(plugin: Phaser.Plugin, parameter: js.Any*): Phaser.Plugin = js.native 37 | 38 | /** 39 | * Clear down this PluginManager, calls destroy on every plugin and nulls out references. 40 | */ 41 | def destroy(): Unit = js.native 42 | 43 | /** 44 | * Post-render is called after the Game Renderer and State.render have run. 45 | * It only calls plugins who have visible=true. 46 | */ 47 | def postRender(): Unit = js.native 48 | 49 | /** 50 | * PostUpdate is the last thing to be called before the world render. 51 | * In particular, it is called after the world postUpdate, which means the camera has been adjusted. 52 | * It only calls plugins who have active=true. 53 | */ 54 | def postUpdate(): Unit = js.native 55 | 56 | /** 57 | * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). 58 | * It only calls plugins who have active=true. 59 | */ 60 | def preUpdate(): Unit = js.native 61 | 62 | /** 63 | * Remove a Plugin from the PluginManager. It calls Plugin.destroy on the plugin before removing it from the manager. 64 | * @param plugin The plugin to be removed. 65 | * @param destroy Call destroy on the plugin that is removed? 66 | */ 67 | def remove(plugin: Phaser.Plugin, destroy: Boolean = js.native): Unit = js.native 68 | 69 | /** 70 | * Remove all Plugins from the PluginManager. It calls Plugin.destroy on every plugin before removing it from the manager. 71 | */ 72 | def removeAll(): Unit = js.native 73 | 74 | /** 75 | * Render is called right after the Game Renderer completes, but before the State.render. 76 | * It only calls plugins who have visible=true. 77 | */ 78 | def render(): Unit = js.native 79 | 80 | /** 81 | * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. 82 | * It only calls plugins who have active=true. 83 | */ 84 | def update(): Unit = js.native 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/PointerMode.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Enumeration categorizing operational modes of pointers. 8 | * 9 | * PointerType values represent valid bitmasks. 10 | * For example, a value representing both Mouse and Touch devices 11 | * can be expressed as PointerMode.CURSOR | PointerMode.CONTACT. 12 | * 13 | * Values may be added for future mode categorizations. 14 | */ 15 | @js.native 16 | @JSGlobal("Phaser.PointerMode") 17 | class PointerMode() extends js.Object 18 | 19 | /** 20 | * Pointer Mode Singleton 21 | * @author lawrence.daniels@gmail.com 22 | */ 23 | @js.native 24 | @JSGlobal("Phaser.PointerMode") 25 | object PointerMode extends js.Object { 26 | 27 | /** 28 | * A 'CONTACT' pointer has an active cursor that only tracks movement when actived; notably this is a touch-style input. 29 | */ 30 | val CONTACT: Int = js.native 31 | 32 | /** 33 | * A 'CURSOR' is a pointer with a passive cursor such as a mouse, touchpad, watcom stylus, or even TV-control arrow-pad. 34 | * 35 | * It has the property that a cursor is passively moved without activating the input. 36 | * This currently corresponds with Phaser.Pointer#isMouse property. 37 | */ 38 | val CURSOR: Int = js.native 39 | 40 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Polygon.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | import scala.scalajs.js.| 6 | 7 | @js.native 8 | @JSGlobal("Phaser.Polygon") 9 | class Polygon(val points: js.Array[Point | js.Array[Double]]) extends js.Object -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/QuadTree.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | import scala.scalajs.js.| 6 | 7 | /** 8 | * A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. 9 | * However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly 10 | * increased performance as a result. 11 | * @param x The top left coordinate of the quadtree. 12 | * @param y The top left coordinate of the quadtree. 13 | * @param width The width of the quadtree in pixels. 14 | * @param height The height of the quadtree in pixels. 15 | * @param maxObjects The maximum number of objects per node. 16 | * @param maxLevels The maximum number of levels to iterate to. 17 | * @param level Which level is this? 18 | * @version 2.6.2 19 | * @see http://phaser.io/docs/2.6.2/Phaser.QuadTree.html 20 | * @author lawrence.daniels@gmail.com 21 | */ 22 | @js.native 23 | @JSGlobal("Phaser.QuadTree") 24 | class QuadTree(var x: Double, 25 | var y: Double, 26 | var width: Double, 27 | var height: Double, 28 | var maxObjects: Int = js.native, 29 | var maxLevels: Int = js.native, 30 | var level: Int = js.native) extends js.Object { 31 | 32 | ///////////////////////////////////////////////////////////////////////////////// 33 | // Properties 34 | ///////////////////////////////////////////////////////////////////////////////// 35 | 36 | /** 37 | * Object that contains the quadtree bounds. 38 | */ 39 | var bounds: js.Any = js.native 40 | 41 | /** 42 | * Array of associated child nodes. 43 | */ 44 | var nodes: js.Array[_] = js.native 45 | 46 | /** 47 | * Array of quadtree children. 48 | */ 49 | var objects: js.Array[_] = js.native 50 | 51 | ///////////////////////////////////////////////////////////////////////////////// 52 | // Methods 53 | ///////////////////////////////////////////////////////////////////////////////// 54 | 55 | /** 56 | * Clear the quadtree. 57 | */ 58 | def clear(): Unit = js.native 59 | 60 | /** 61 | * Determine which node the object belongs to. 62 | * @param rect The bounds in which to check. 63 | * @return index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is 64 | * part of the parent node. 65 | */ 66 | def getIndex(rect: Phaser.Rectangle): Int = js.native 67 | 68 | /** 69 | * Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to 70 | * their corresponding subnodes. 71 | * @param body The Body object to insert into the quadtree. Can be any object so long as it exposes x, y, right 72 | * and bottom properties. 73 | */ 74 | def insert(body: Phaser.Physics.Arcade.Body): Unit = js.native 75 | 76 | /** 77 | * Populates this quadtree with the children of the given Group. In order to be added the child must exist 78 | * and have a body property. 79 | * @param group The Group to add to the quadtree. 80 | */ 81 | def populate[T](group: Phaser.Group[T]): Unit = js.native 82 | 83 | /** 84 | * Handler for the populate method. 85 | * @param sprite The Sprite to check. 86 | */ 87 | def populateHandler(sprite: Phaser.Sprite): Unit = js.native 88 | 89 | /** 90 | * Resets the QuadTree. 91 | * @param x The top left coordinate of the quadtree. 92 | * @param y The top left coordinate of the quadtree. 93 | * @param width The width of the quadtree in pixels. 94 | * @param height The height of the quadtree in pixels. 95 | * @param maxObjects The maximum number of objects per node. 96 | * @param maxLevels The maximum number of levels to iterate to. 97 | * @param level Which level is this? 98 | */ 99 | def reset(x: Double, y: Double, width: Double, height: Double, maxObjects: Int = js.native, maxLevels: Int = js.native, level: Int = js.native): Unit = js.native 100 | 101 | /** 102 | * Return all objects that could collide with the given Sprite or Rectangle. 103 | * @param source The source object to check the QuadTree against. Either a Sprite or Rectangle. 104 | * @return Array with all detected objects. 105 | */ 106 | def retrieve[T](source: Phaser.Sprite | Phaser.Rectangle): js.Array[T] = js.native 107 | 108 | /** 109 | * Split the node into 4 subnodes 110 | */ 111 | def split(): Unit = js.native 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/RandomDataGenerator.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait RandomDataGenerator extends js.Object { 7 | def integerInRange(min: Int, max: Int): Int = js.native 8 | } 9 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Rectangle.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | 5 | /** 6 | * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified 7 | * width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height 8 | * properties set to 0 is created. 9 | * @param x The x coordinate of the top-left corner of the Rectangle. 10 | * @param y The y coordinate of the top-left corner of the Rectangle. 11 | * @param width The width of the Rectangle. Should always be either zero or a positive value. 12 | * @param height The height of the Rectangle. Should always be either zero or a positive value. 13 | */ 14 | @js.native 15 | class Rectangle(var x: Int, var y: Int, var width: Int, var height: Int) extends js.Object { 16 | 17 | /** 18 | * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on 19 | * the x, y and width properties, but does change the height property. 20 | */ 21 | var bottom: Double = js.native 22 | 23 | /** 24 | * The location of the Rectangles bottom left corner as a Point object. Gets or sets the location of the Rectangles 25 | * bottom left corner as a Point object. 26 | */ 27 | var bottomLeft: Point = js.native 28 | 29 | /** 30 | * The location of the Rectangles bottom right corner as a Point object. Gets or sets the location of the Rectangles 31 | * bottom right corner as a Point object. 32 | */ 33 | var bottomRight: Point = js.native 34 | 35 | /** 36 | * The x coordinate of the center of the Rectangle. 37 | */ 38 | var centerX: Double = js.native 39 | 40 | /** 41 | * The y coordinate of the center of the Rectangle. 42 | */ 43 | var centerY: Double = js.native 44 | 45 | /** 46 | * Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is 47 | * less than or equal to 0. If set to true then all of the Rectangle properties are set to 0. Gets or sets the 48 | * Rectangles empty state. 49 | */ 50 | var empty: Boolean = js.native 51 | 52 | /** 53 | * Half of the height of the Rectangle. 54 | */ 55 | def halfHeight: Double = js.native 56 | 57 | /** 58 | * Half of the width of the Rectangle. 59 | */ 60 | def halfWidth: Double = js.native 61 | 62 | /** 63 | * The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect 64 | * on the y and height properties. However it does affect the width property, whereas changing the x value does 65 | * not affect the width property. 66 | */ 67 | var left: Double = js.native 68 | 69 | /** 70 | * The perimeter size of the Rectangle. This is the sum of all 4 sides. 71 | */ 72 | def perimeter: Double = js.native 73 | 74 | /** 75 | * A random value between the left and right values (inclusive) of the Rectangle. 76 | */ 77 | var randomX: Double = js.native 78 | 79 | /** 80 | * A random value between the top and bottom values (inclusive) of the Rectangle. 81 | */ 82 | var randomY: Double = js.native 83 | 84 | /** 85 | * The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on 86 | * the x, y and height properties, however it does affect the width property. 87 | */ 88 | var right: Double = js.native 89 | 90 | /** 91 | * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on 92 | * the x and width properties. However it does affect the height property, whereas changing the y value does not 93 | * affect the height property. 94 | */ 95 | var top: Double = js.native 96 | 97 | /** 98 | * The location of the Rectangles top left corner as a Point object. 99 | */ 100 | var topLeft: Point = js.native 101 | 102 | /** 103 | * The location of the Rectangles top right corner as a Point object. The location of the Rectangles top left 104 | * corner as a Point object. 105 | */ 106 | var topRight: Point = js.native 107 | 108 | /** 109 | * The const type of this object. 110 | */ 111 | def `type`: Int = js.native 112 | 113 | /** 114 | * The volume of the Rectangle derived from width * height. 115 | */ 116 | def volume: Double = js.native 117 | 118 | } 119 | 120 | @js.native 121 | object Rectangle extends js.Object { 122 | 123 | /** 124 | * @param a The Rectangle object. 125 | * @param output Optional: Rectangle object. If given the values will be set into the object, otherwise a brand new 126 | * Rectangle object will be created and returned. 127 | * @return a new Rectangle object with the same values for the x, y, width, and height properties as the original 128 | * Rectangle object. 129 | */ 130 | def clone(a: Rectangle, output: Rectangle = js.native): this.type = js.native 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/RenderTexture.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.RenderTexture") 8 | class RenderTexture extends js.Object 9 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/RoundedRectangle.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | 5 | /** 6 | * The Rounded Rectangle object is an area defined by its position and has nice rounded corners, as indicated by its 7 | * top-left corner point (x, y) and by its width and its height. 8 | * @param x The x coordinate of the top-left corner of the Rectangle. 9 | * @param y The y coordinate of the top-left corner of the Rectangle. 10 | * @param width The width of the Rectangle. Should always be either zero or a positive value. 11 | * @param height The height of the Rectangle. Should always be either zero or a positive value. 12 | * @param radius Controls the radius of the rounded corners. 13 | */ 14 | @js.native 15 | class RoundedRectangle(x: Int, y: Int, width: Int, height: Int, radius: Int) extends js.Object { 16 | 17 | /** 18 | * The const type of this object. 19 | */ 20 | def `type`: Int = js.native 21 | 22 | /** 23 | * @return a new RoundedRectangle object with the same values for the x, y, width, height and radius properties 24 | * as this RoundedRectangle object. 25 | */ 26 | override def clone(): this.type = js.native 27 | 28 | /** 29 | * Determines whether the specified coordinates are contained within the region defined by this Rounded Rectangle object. 30 | * @param x The x coordinate of the point to test. 31 | * @param y The y coordinate of the point to test. 32 | * @return A value of true if the RoundedRectangle Rectangle object contains the specified point; otherwise false. 33 | */ 34 | def contains(x: Int, y: Int): Boolean = js.native 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/ScaleManager.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.JsNumber 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | import scala.scalajs.js.| 8 | 9 | /** 10 | * Create a new ScaleManager object - this is done automatically by [[Phaser.Game]] 11 | * 12 | * The width and height constructor parameters can either be a number which represents pixels or a string that 13 | * represents a percentage: e.g. 800 (for 800 pixels) or "80%" for 80%. 14 | * @param game A reference to the currently running game. 15 | * @param width The width of the game. See above. 16 | * @param height The height of the game. See above. 17 | * @see https://phaser.io/docs/2.6.2/Phaser.ScaleManager.html 18 | */ 19 | @js.native 20 | @JSGlobal("Phaser.ScaleManager") 21 | class ScaleManager(var game: Phaser.Game, val width: JsNumber | String, val height: JsNumber | String) 22 | extends js.Object 23 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Signal.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.Signal") 8 | class Signal extends js.Object { 9 | 10 | def addOnce(listener: js.ThisFunction0[_, _], listenerContext: Any, priority: Int, args: Any*): SignalBinding = 11 | js.native 12 | 13 | def addOnce(listener: js.ThisFunction0[_, _], listenerContext: Any = this, priority: Int = 0): SignalBinding = 14 | js.native 15 | 16 | def add(listener: js.ThisFunction0[_, _], listenerContext: Any, priority: Int, args: Any*): SignalBinding = js.native 17 | 18 | def add(listener: js.ThisFunction0[_, _], listenerContext: Any = this, priority: Int = 0): SignalBinding = js.native 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/SignalBinding.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.SignalBinding") 8 | class SignalBinding extends js.Object -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/SinglePad.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Created by ldaniels on 2/3/17. 8 | */ 9 | @js.native 10 | @JSGlobal("Phaser.SinglePad") 11 | class SinglePad extends js.Object { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Sound.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * The Sound class constructor. 8 | * @param game Reference to the current game instance. 9 | * @param key Asset key for the sound. 10 | * @param volume Default value for the volume, between 0 and 1. 11 | * @param loop Whether or not the sound will loop. 12 | */ 13 | @js.native 14 | @JSGlobal("Phaser.Sound") 15 | class Sound(var game: Phaser.Game, val key: String, val volume: Int = js.native, val loop: Boolean = js.native) 16 | extends js.Object 17 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Sprite.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.dom.html.pixijs 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSGlobal 7 | import scala.scalajs.js.| 8 | 9 | /** 10 | * Sprites are the lifeblood of your game, used for nearly everything visual. 11 | * At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. 12 | * They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), 13 | * events (via Sprite.events), animation (via Sprite.animations), camera culling and more. 14 | * Please see the Examples for use cases. 15 | * @see http://phaser.io/docs/2.6.2/Phaser.Sprite.html 16 | */ 17 | @js.native 18 | @JSGlobal("Phaser.Sprite") 19 | class Sprite(var game: Phaser.Game, 20 | override var x: Double, 21 | override var y: Double, 22 | var key: String | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Texture, 23 | var frame: String | Int) 24 | extends pixijs.Sprite 25 | with Phaser.Component.Core 26 | with Phaser.Component.Angle 27 | with Phaser.Component.Animation 28 | with Phaser.Component.AutoCull 29 | with Phaser.Component.Bounds 30 | with Phaser.Component.BringToTop 31 | with Phaser.Component.Crop 32 | with Phaser.Component.Delta 33 | with Phaser.Component.Destroy 34 | with Phaser.Component.FixedToCamera 35 | with Phaser.Component.Health 36 | with Phaser.Component.InCamera 37 | with Phaser.Component.InputEnabled 38 | with Phaser.Component.InWorld 39 | with Phaser.Component.LifeSpan 40 | with Phaser.Component.LoadTexture 41 | with Phaser.Component.Overlap 42 | with Phaser.Component.PhysicsBody 43 | with Phaser.Component.Reset 44 | with Phaser.Component.ScaleMinMax 45 | with Phaser.Component.Smoothed { 46 | 47 | /** 48 | * Protected constructor 49 | */ 50 | protected def this() = this(js.native, js.native, js.native, js.native, js.native) 51 | 52 | /** 53 | * The angle property is the rotation of the Game Object in degrees from its original orientation. 54 | * 55 | * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 56 | * 57 | * Values outside this range are added to or subtracted from 360 to obtain a value within the range. 58 | * For example, the statement player.angle = 450 is the same as player.angle = 90. 59 | * 60 | * If you wish to work in radians instead of degrees you can use the property rotation instead. 61 | * Working in radians is slightly faster as it doesn't have to perform any calculations. 62 | */ 63 | override var angle: Double = js.native 64 | 65 | /** 66 | * The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode. 67 | * Warning: You cannot have a blend mode and a filter active on the same Sprite. Doing so will render the sprite invisible. 68 | */ 69 | var blendMode: Double = js.native 70 | 71 | /** 72 | * Base destroy method for generic display objects. 73 | */ 74 | override def destroy(): Unit = js.native 75 | 76 | /** 77 | * Base destroy method for generic display objects. 78 | */ 79 | override def destroy(destroyChildren: Boolean): Unit = js.native 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/State.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.State") 8 | class State extends js.Object { 9 | 10 | def add(name: String, state: GameState): Unit = js.native 11 | 12 | def start(name: String): Unit = js.native 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Text.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import io.scalajs.{JsNumber, RawOptions} 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.{JSGlobal, JSName, ScalaJSDefined} 7 | import scala.scalajs.js.| 8 | 9 | /** 10 | * Create a new game object for displaying Text. 11 | * 12 | * This uses a local hidden Canvas object and renders the type into it. It then makes a texture from this for rendering to the view. 13 | * Because of this you can only display fonts that are currently loaded and available to the browser: fonts must be pre-loaded. 14 | * @param game Current game instance. 15 | * @param x X position of the new text object. 16 | * @param y Y position of the new text object. 17 | * @param text The actual text that will be written. 18 | * @param style The style properties to be set on the Text. 19 | */ 20 | @js.native 21 | @JSGlobal("Phaser.Text") 22 | class Text(game: Phaser.Game, 23 | x: Double, 24 | y: Double, 25 | var text: String, 26 | var style: StyleOptions | RawOptions = js.native) extends Sprite 27 | 28 | /** 29 | * Text Style Options 30 | * @param font The style and size of the font. 31 | * @param fontStyle The style of the font (eg. 'italic'): overrides the value in style.font. 32 | * @param fontVariant The variant of the font (eg. 'small-caps'): overrides the value in style.font. 33 | * @param fontWeight The weight of the font (eg. 'bold'): overrides the value in style.font 34 | * @param fontSize The size of the font (eg. 32 or '32px'): overrides the value in style.font. 35 | * @param backgroundColor A canvas fillstyle that will be used as the background for the whole Text object. 36 | * Set to null to disable. 37 | * @param fill A canvas fillstyle that will be used on the text eg 'red', '#00FF00'. 38 | * @param align Horizontal alignment of each line in multiline text. Can be: 'left', 'center' or 'right'. 39 | * Does not affect single lines of text (see textBounds and boundsAlignH for that). 40 | * @param boundsAlignH Horizontal alignment of the text within the textBounds. Can be: 'left', 'center' or 'right'. 41 | * @param boundsAlignV Vertical alignment of the text within the textBounds. Can be: 'top', 'middle' or 'bottom'. 42 | * @param stroke A canvas stroke style that will be used on the text stroke eg 'blue', '#FCFF00'. 43 | * @param strokeThickness A number that represents the thickness of the stroke. Default is 0 (no stroke). 44 | * @param wordWrap Indicates if word wrap should be used. 45 | * @param wordWrapWidth The width in pixels at which text will wrap. 46 | * @param maxLines The maximum number of lines to be shown for wrapped text. 47 | * @param tabs The size (in pixels) of the tabs, for when text includes tab characters. 48 | * 0 disables. Can be an array of varying tab sizes, one per tab stop. 49 | */ 50 | 51 | class StyleOptions(var font: js.UndefOr[String] = js.undefined, 52 | var fontStyle: js.UndefOr[String] = js.undefined, 53 | var fontVariant: js.UndefOr[String] = js.undefined, 54 | var fontWeight: js.UndefOr[String] = js.undefined, 55 | var fontSize: js.UndefOr[String | JsNumber] = js.undefined, 56 | var backgroundColor: js.UndefOr[String] = js.undefined, 57 | var fill: js.UndefOr[String] = js.undefined, 58 | var align: js.UndefOr[String] = js.undefined, 59 | var boundsAlignH: js.UndefOr[String] = js.undefined, 60 | var boundsAlignV: js.UndefOr[String] = js.undefined, 61 | var stroke: js.UndefOr[String] = js.undefined, 62 | var strokeThickness: js.UndefOr[String] = js.undefined, 63 | var wordWrap: js.UndefOr[Boolean] = js.undefined, 64 | var wordWrapWidth: js.UndefOr[JsNumber] = js.undefined, 65 | var maxLines: js.UndefOr[JsNumber] = js.undefined, 66 | var tabs: js.UndefOr[JsNumber] = js.undefined) extends js.Object -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Texture.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.Texture") 8 | class Texture extends js.Object -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/TileSprite.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | @JSGlobal("Phaser.TileSprite") 8 | class TileSprite extends js.Object { 9 | val tilePosition: Point = js.native 10 | } 11 | -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Tilemap.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file. 8 | * 9 | * Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org 10 | * 11 | * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. 12 | * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. 13 | * If creating a blank tilemap to be populated later, you can either specify no parameters at 14 | * all and then use Tilemap.create or pass the map and tile dimensions here. 15 | * 16 | * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a 17 | * TilemapLayer may have its own unique tile size that overrides it. 18 | * 19 | * A Tile map is rendered to the display using a TilemapLayer. It is not added to the display list directly itself. 20 | * A map may have multiple layers. You can perform operations on the map data such as copying, 21 | * pasting, filling and shuffling the tiles around. 22 | * @param game Game reference to the currently running game. 23 | * @param key The key of the tilemap data as stored in the Cache. If you're creating a blank map 24 | * either leave this parameter out or pass null. 25 | * @param tileWidth The pixel width of a single map tile. If using CSV data you must specify this. 26 | * Not required if using Tiled map data. 27 | * @param tileHeight The pixel height of a single map tile. If using CSV data you must specify this. 28 | * Not required if using Tiled map data. 29 | * @param width The width of the map in tiles. If this map is created from Tiled or CSV data 30 | * you don't need to specify this. 31 | * @param height The height of the map in tiles. If this map is created from Tiled or CSV data 32 | * you don't need to specify this. 33 | * @see http://phaser.io/docs/2.6.2/Phaser.Tilemap.html 34 | */ 35 | @js.native 36 | @JSGlobal("Phaser.Tilemap") 37 | class Tilemap(var game: Phaser.Game, 38 | var key: String = js.native, 39 | var tileWidth: Double = js.native, 40 | var tileHeight: Double = js.native, 41 | var width: Double = js.native, 42 | var height: Double = js.native) extends js.Object { 43 | 44 | /** 45 | * An array of tile indexes that collide. 46 | */ 47 | var collideIndexes: js.Array[Int] = js.native 48 | 49 | /** 50 | * An array of collision data (polylines, etc). 51 | */ 52 | var collision: js.Array[_] = js.native 53 | 54 | /** 55 | * The current layer. 56 | */ 57 | var currentLayer: Int = js.native 58 | 59 | /** 60 | * Map data used for debug values only. 61 | */ 62 | var debugMap: js.Array[_] = js.native 63 | 64 | /** 65 | * If set then console.log is used to dump out useful layer creation debug data. 66 | */ 67 | var enableDebug: Boolean = js.native 68 | 69 | } 70 | 71 | /** 72 | * Tilemap Singleton 73 | */ 74 | @js.native 75 | @JSGlobal("Phaser.Tilemap") 76 | object Tilemap extends js.Object { 77 | 78 | /** 79 | * 80 | */ 81 | val CSV: Int = js.native 82 | 83 | /** 84 | * 85 | */ 86 | val EAST: Int = js.native 87 | 88 | /** 89 | * 90 | */ 91 | val NORTH: Int = js.native 92 | 93 | /** 94 | * 95 | */ 96 | val SOUTH: Int = js.native 97 | 98 | /** 99 | * 100 | */ 101 | val TILED_JSON: Int = js.native 102 | 103 | /** 104 | * 105 | */ 106 | val WEST: Int = js.native 107 | 108 | } -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/TilemapLayer.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.{JSGlobal, JSName, ScalaJSDefined} 5 | import scala.scalajs.js.| 6 | 7 | /** 8 | * A TilemapLayer is a Phaser.Image/Sprite that renders a specific TileLayer of a Tilemap. 9 | * 10 | * Since a TilemapLayer is a Sprite it can be moved around the display, added to other 11 | * groups or display objects, etc. 12 | * 13 | * By default TilemapLayers have fixedToCamera set to true. Changing this will break 14 | * Camera follow and scrolling behavior. 15 | * @param game Game reference to the currently running game. 16 | * @param tilemap The tilemap to which this layer belongs. 17 | * @param index The index of the TileLayer to render within the Tilemap. 18 | * @param width Width of the renderable area of the layer (in pixels). 19 | * @param height Height of the renderable area of the layer (in pixels). 20 | * @see http://phaser.io/docs/2.6.2/Phaser.TilemapLayer.html 21 | */ 22 | @js.native 23 | @JSGlobal("Phaser.TilemapLayer") 24 | class TilemapLayer(game: Phaser.Game, 25 | var tilemap: Phaser.Tilemap, 26 | var index: Int, 27 | width: Double, 28 | height: Double) extends Phaser.Sprite { 29 | 30 | /** 31 | * Settings used for debugging and diagnostics. 32 | */ 33 | var debugSettings: DebugSettings = js.native 34 | 35 | } 36 | 37 | /** 38 | * Settings used for debugging and diagnostics. 39 | * @param missingImageFill A tile is rendered as a rectangle using the following fill if a valid 40 | * tileset/image cannot be found. A value of null prevents additional 41 | * rendering for tiles without a valid tileset image. This takes effect 42 | * even when debug rendering for the layer is not enabled. 43 | * @param debuggedTileOverfill If a Tile has Tile#debug true then, after normal tile image rendering, 44 | * a rectangle with the following fill is drawn above/over it. This takes 45 | * effect even when debug rendering for the layer is not enabled. 46 | * @param forceFullRedraw When debug rendering (debug is true), and this option is enabled, 47 | * a full redraw is forced and rendering optimization is suppressed. 48 | * @param debugAlpha When debug rendering (debug is true), the tileset is initially rendered 49 | * with this alpha level. This can make the tile edges clearer. 50 | * @param facingEdgeStroke When debug rendering (debug is true), this color/stroke is used to draw 51 | * "face" edges. A value of null disables coloring facing edges. 52 | * @param collidingTileOverfill When debug rendering (debug is true), this fill is used for tiles that are 53 | * collidable. A value of null disables applying the additional overfill. 54 | */ 55 | 56 | class DebugSettings(var missingImageFill: js.UndefOr[String] = js.undefined, 57 | var debuggedTileOverfill: js.UndefOr[String] = js.undefined, 58 | var forceFullRedraw: js.UndefOr[Boolean] = js.undefined, 59 | var debugAlpha: js.UndefOr[Double | Int] = js.undefined, 60 | var facingEdgeStroke: js.UndefOr[String] = js.undefined, 61 | var collidingTileOverfill: js.UndefOr[String] = js.undefined) extends js.Object -------------------------------------------------------------------------------- /src/main/scala/io/scalajs/dom/html/phaser/Time.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.dom.html.phaser 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | /** 7 | * This is the core internal game clock. 8 | * 9 | * It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens, 10 | * and also handles the standard Timer pool. 11 | * 12 | * To create a general timed event, use the master [[Phaser.Timer]] accessible through events. 13 | * @param game A reference to the currently running game. 14 | * @author lawrence.daniels@gmail.com 15 | */ 16 | @js.native 17 | @JSGlobal("Phaser.Time") 18 | class Time(var game: Phaser.Game) extends js.Object { 19 | 20 | ///////////////////////////////////////////////////////////////////////////////// 21 | // Properties 22 | ///////////////////////////////////////////////////////////////////////////////// 23 | 24 | /** 25 | * If true then advanced profiling, including the fps rate, fps min/max, suggestedFps and msMin/msMax are updated. 26 | */ 27 | var advancedTiming: Boolean = js.native 28 | 29 | /** 30 | * The desired frame rate of the game. 31 | * 32 | * This is used is used to calculate the physic / logic multiplier and how to apply catch-up logic updates. 33 | * The desired frame rate of the game. Defaults to 60. 34 | */ 35 | var desiredFps: Int = js.native 36 | 37 | /** 38 | * A [[Phaser.Timer]] object bound to the master clock (this Time object) which events can be added to. 39 | */ 40 | def events: Phaser.Timer = js.native 41 | 42 | /** 43 | * Advanced timing result: Frames per second. 44 | * 45 | * Only calculated if [[advancedTiming]] is enabled. 46 | * @return 47 | */ 48 | def fps: Double = js.native 49 | 50 | /** 51 | * Advanced timing result: The highest rate the fps has reached (usually no higher than 60fps). 52 | * 53 | * Only calculated if [[advancedTiming]] is enabled. 54 | * This value can be manually reset. 55 | */ 56 | def fpsMax: Double = js.native 57 | 58 | /** 59 | * Advanced timing result: The lowest rate the fps has dropped to. 60 | * 61 | * Only calculated if [[advancedTiming]] is enabled. 62 | * This value can be manually reset. 63 | */ 64 | var fpsMin: Double = js.native 65 | 66 | /** 67 | * Advanced timing result: The number of render frames record in the last second. 68 | * 69 | * Only calculated if [[advancedTiming]] is enabled. 70 | */ 71 | def frames: Int = js.native 72 | 73 | /** 74 | * Advanced timing result: The maximum amount of time the game has taken between consecutive frames. 75 | * 76 | * Only calculated if [[advancedTiming]] is enabled. 77 | * This value can be manually reset. 78 | */ 79 | def msMax: Double = js.native 80 | 81 | /** 82 | * Advanced timing result: The minimum amount of time the game has taken between consecutive frames. 83 | * 84 | * Only calculated if [[advancedTiming]] is enabled. 85 | * This value can be manually reset. 86 | */ 87 | def msMin: Double = js.native 88 | 89 | /** 90 | * An increasing value representing cumulative milliseconds since an undisclosed epoch. 91 | * 92 | * While this value is in milliseconds and can be used to compute time deltas, 93 | * it must must not be used with `Date.now()` as it may not use the same epoch / starting reference. 94 | * 95 | * The source may either be from a high-res source (eg. if RAF is available) or the standard `Date.now`; 96 | * the value can only be relied upon within a particular game instance. 97 | */ 98 | def now: Double = js.native 99 | 100 | /** 101 | * Records how long the game was last paused, in milliseconds. 102 | * (This is not updated until the game is resumed.) 103 | */ 104 | def pauseDuration: Double = js.native 105 | 106 | /** 107 | * The physics update delta, in fractional seconds. 108 | * 109 | * This should be used as an applicable multiplier by all logic update steps (eg. `preUpdate/postUpdate/update`) 110 | * to ensure consistent game timing. Game/logic timing can drift from real-world time if the system 111 | * is unable to consistently maintain the desired FPS. 112 | * 113 | * With fixed-step updates this is normally equivalent to `1.0 / desiredFps`. 114 | */ 115 | def physicsElapsed: Double = js.native 116 | 117 | /** 118 | * The physics update delta, in milliseconds - equivalent to `physicsElapsed * 1000`. 119 | */ 120 | def physicsElapsedMS: Double = js.native 121 | 122 | /** 123 | * Scaling factor to make the game move smoothly in slow motion 124 | *