├── .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 | *
125 | * - 1.0 = normal speed
126 | * - 2.0 = half speed
127 | *
128 | */
129 | def slowMotion: Double = js.native
130 |
131 | /**
132 | * The suggested frame rate for your game, based on an averaged real frame rate.
133 | * This value is only populated if [[Time.advancedTiming]] is enabled.
134 | *
135 | * Note: This is not available until after a few frames have passed; until then
136 | * it's set to the same value as desiredFps.
137 | */
138 | def suggestedFps: Double = js.native
139 |
140 | /////////////////////////////////////////////////////////////////////////////////
141 | // Methods
142 | /////////////////////////////////////////////////////////////////////////////////
143 |
144 | /**
145 | * Adds an existing Phaser.Timer object to the Timer pool.
146 | * @param timer An existing [[Phaser.Timer]] object.
147 | * @return The given [[Phaser.Timer]] object.
148 | */
149 | def add(timer: Phaser.Timer): Phaser.Timer = js.native
150 |
151 | /**
152 | * Creates a new stand-alone Phaser.Timer object.
153 | * @param autoDestroy A Timer that is set to automatically destroy itself will do so after all of its events have
154 | * been dispatched (assuming no looping events).
155 | * @return The [[Phaser.Timer Timer]] object that was created.
156 | */
157 | def create(autoDestroy: Boolean = js.native): Phaser.Timer = js.native
158 |
159 | /**
160 | * How long has passed since the given time (in seconds).
161 | * @param since The time you want to measure (in seconds).
162 | * @return Duration between given time and now (in seconds).
163 | */
164 | def elapsedSecondsSince(since: Double): Double = js.native
165 |
166 | /**
167 | * How long has passed since the given time.
168 | * @param since The time you want to measure against.
169 | * @return The difference between the given time and now.
170 | */
171 | def elapsedSince(since: Double): Double = js.native
172 |
173 | /**
174 | * Refreshes the Time.time and Time.elapsedMS properties from the system clock.
175 | */
176 | def refresh(): Unit = js.native
177 |
178 | /**
179 | * Remove all Timer objects, regardless of their state and clears all Timers from the events timer.
180 | */
181 | def removeAll(): Unit = js.native
182 |
183 | /**
184 | * Resets the private _started value to now and removes all currently running Timers.
185 | */
186 | def reset(): Unit = js.native
187 |
188 | /**
189 | * The number of seconds that have elapsed since the game was started.
190 | */
191 | def totalElapsedSeconds(): Double = js.native
192 |
193 | }
194 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/Timer.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 Timer is a way to create and manage timer events that wait for a specific duration and then run a callback.
8 | * Many different timer events, with individual delays, can be added to the same Timer.
9 | *
10 | * All Timer delays are in milliseconds (there are 1000 ms in 1 second); so a delay value of 250 represents a quarter of a second.
11 | *
12 | * Timers are based on real life time, adjusted for game pause durations.
13 | * That is, timer events are based on elapsed game time and do not take physics time or slow motion into account.
14 | * @param game A reference to the currently running game.
15 | * @param autoDestroy If true, the timer will automatically destroy itself after all the events have been dispatched
16 | * (assuming no looping events).
17 | * @author lawrence.daniels@gmail.com
18 | */
19 | @js.native
20 | @JSGlobal("Phaser.Timer")
21 | class Timer(var game: Phaser.Game, val autoDestroy: Boolean = js.native) extends js.Object {
22 |
23 | /**
24 | * The duration in ms remaining until the next event will occur.
25 | */
26 | def duration: Double = js.native
27 |
28 | /**
29 | * An array holding all of this timers Phaser.TimerEvent objects. Use the methods add, repeat and loop to populate it.
30 | */
31 | def events: js.Array[Phaser.TimerEvent] = js.native
32 |
33 | /**
34 | * An expired Timer is one in which all of its events have been dispatched and none are pending.
35 | */
36 | def expired: Boolean = js.native
37 |
38 | /**
39 | * The number of pending events in the queue.
40 | */
41 | def length: Int = js.native
42 |
43 | /**
44 | * The duration in milliseconds that this Timer has been running for.
45 | */
46 | def ms: Double = js.native
47 |
48 | /**
49 | * The time at which the next event will occur.
50 | */
51 | def next: Double = js.native
52 |
53 | /**
54 | * This signal will be dispatched when this Timer has completed which means that there are no more events in the queue.
55 | *
56 | * The signal is supplied with one argument, `timer`, which is this Timer object.
57 | */
58 | def onComplete: Phaser.Signal = js.native
59 |
60 | /**
61 | * The paused state of the Timer. You can pause the timer by calling Timer.pause() and Timer.resume() or by the game pausing.
62 | */
63 | def paused: Boolean = js.native
64 |
65 | /**
66 | * True if the Timer is actively running.
67 | *
68 | * Do not modify this boolean - use pause (and resume) to pause the timer.
69 | */
70 | def running: Boolean = js.native
71 |
72 | /**
73 | * The duration in seconds that this Timer has been running for.
74 | */
75 | def seconds: Double = js.native
76 |
77 | /**
78 | * If the difference in time between two frame updates exceeds this value, the event times are reset to avoid catch-up situations.
79 | */
80 | def timeCap: Double = js.native
81 |
82 | }
83 |
84 | /**
85 | * Timer Singleton
86 | */
87 | @js.native
88 | @JSGlobal("Phaser.Timer")
89 | object Timer extends js.Object {
90 | val HALF: Int = js.native
91 | val MINUTE: Int = js.native
92 | val QUARTER: Int = js.native
93 | val SECOND: Int = js.native
94 |
95 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/TimerEvent.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 TimerEvent is a single event that is processed by a Phaser.Timer.
8 | *
9 | * It consists of a delay, which is a value in milliseconds after which the event will fire.
10 | * When the event fires it calls a specific callback with the specified arguments.
11 | *
12 | * TimerEvents are removed by their parent timer once finished firing or repeating.
13 | *
14 | * Use [[Phaser.Timer]]#add, [[Phaser.Timer]]#repeat, or [[Phaser.Timer]]#loop methods to create a new event.
15 | * @param timer The Timer object that this TimerEvent belongs to.
16 | * @param delay The delay in ms at which this TimerEvent fires.
17 | * @param tick The tick is the next game clock time that this event will fire at.
18 | * @param repeatCount If this TimerEvent repeats it will do so this many times.
19 | * @param loop True if this TimerEvent loops, otherwise false.
20 | * @param callback The callback that will be called when the TimerEvent occurs.
21 | * @param callbackContext The context in which the callback will be called.
22 | * @param arguments Additional arguments to be passed to the callback.
23 | */
24 | @js.native
25 | @JSGlobal("Phaser.TimerEvent")
26 | class TimerEvent(val timer: Phaser.Timer,
27 | val delay: Double,
28 | val tick: Double,
29 | val repeatCount: Int,
30 | val loop: Boolean,
31 | val callback: js.Function,
32 | val callbackContext: js.Any,
33 | val arguments: js.Array[_]) extends js.Object
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/Tween.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.Tween")
8 | class Tween extends js.Object {
9 |
10 | def to(properties: js.Dictionary[_],
11 | duration: Int = 1000,
12 | ease: Any = null,
13 | autoStart: Boolean = false,
14 | delay: Int = 0,
15 | repeat: Int = 0,
16 | yoyo: Boolean = false): Tween = js.native
17 |
18 | def onLoop: Signal = js.native
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/Video.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * A Video object that takes a previously loaded Video from the Phaser Cache and handles playback of it.
7 | *
8 | * Alternatively it takes a getUserMedia feed from an active webcam and streams the contents of that to
9 | * the Video instead (see startMediaStream method)
10 | *
11 | * The video can then be applied to a Sprite as a texture. If multiple Sprites share the same Video texture and playback
12 | * changes (i.e. you pause the video, or seek to a new time) then this change will be seen across all Sprites simultaneously.
13 | *
14 | * Due to a bug in IE11 you cannot play a video texture to a Sprite in WebGL. For IE11 force Canvas mode.
15 | *
16 | * If you need each Sprite to be able to play a video fully independently then you will need one Video object per Sprite.
17 | * Please understand the obvious performance implications of doing this, and the memory required to hold videos in RAM.
18 | *
19 | * On some mobile browsers such as iOS Safari, you cannot play a video until the user has explicitly touched the screen.
20 | * This works in the same way as audio unlocking. Phaser will handle the touch unlocking for you, however unlike with audio
21 | * it's worth noting that every single Video needs to be touch unlocked, not just the first one. You can use the changeSource
22 | * method to try and work around this limitation, but see the method help for details.
23 | *
24 | * Small screen devices, especially iPod and iPhone will launch the video in its own native video player,
25 | * outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation.
26 | *
27 | * Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends)
28 | * then you need to add your own event listener
29 | * @param game A reference to the currently running game.
30 | * @param key The key of the video file in the [[Phaser.Cache]] that this Video object will play.
31 | * Set to null or leave undefined if you wish to use a webcam as the source.
32 | * See startMediaStream to start webcam capture.
33 | * @param url If the video hasn't been loaded then you can provide a full URL to the
34 | * file here (make sure to set key to null)
35 | * @see http://phaser.io/docs/2.6.2/Phaser.Video.html
36 | */
37 | @js.native
38 | class Video(var game: Phaser.Game, var key: String, var url: String) extends js.Object {
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/World.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * A game has only one world. The world is an abstract place in which all game objects live. It is not bound by stage
7 | * limits and can be any size. You look into the world via cameras. All game objects live within the world at
8 | * world-based coordinates. By default a world is created the same size as your Stage.
9 | * @param game Reference to the current game instance.
10 | */
11 | @js.native
12 | class World(var game: Phaser.Game) extends js.Object {
13 |
14 | /**
15 | * The alive property is useful for Groups that are children of other Groups and need to be included/excluded in
16 | * checks like forEachAlive.
17 | */
18 | var alive: Boolean = js.native
19 |
20 | /**
21 | * The x coordinate of the center of the Rectangle.
22 | */
23 | var centerX: Double = js.native
24 |
25 | /**
26 | * The y coordinate of the center of the Rectangle.
27 | */
28 | var centerY: Double = js.native
29 |
30 | /**
31 | * The height of the Rectangle. This value should never be set to a negative.
32 | */
33 | var height: Double = js.native
34 |
35 | /**
36 | * The width of the Rectangle. This value should never be set to a negative.
37 | */
38 | var width: Double = js.native
39 |
40 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Angle.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 |
5 | @js.native
6 | //@JSGlobal("Phaser.Component.Angle")
7 | trait Angle extends js.Object {
8 |
9 | /**
10 | * The angle property is the rotation of the Game Object in degrees from its original orientation.
11 | *
12 | * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
13 | *
14 | * Values outside this range are added to or subtracted from 360 to obtain a value within the range.
15 | * For example, the statement player.angle = 450 is the same as player.angle = 90.
16 | *
17 | * If you wish to work in radians instead of degrees you can use the property rotation instead.
18 | * Working in radians is slightly faster as it doesn't have to perform any calculations.
19 | */
20 | def angle: Double = js.native
21 |
22 | def angle_=(angle: Double): Unit = js.native
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Animation.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.Animation")
8 | trait Animation extends js.Object {
9 |
10 | def play(key: String, frameRate: Double = 60, loop: Boolean = false, killOnComplete: Boolean = false): Animation =
11 | js.native
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/AutoCull.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.AutoCull")
8 | trait AutoCull extends js.Object {
9 |
10 | /**
11 | * A Game Object with `autoCull` set to true will check its bounds against the World Camera every frame.
12 | * If it is not intersecting the Camera bounds at any point then it has its `renderable` property set to `false`.
13 | * This keeps the Game Object alive and still processing updates, but forces it to skip the render step entirely.
14 | * *
15 | * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required,
16 | * or you have tested performance and find it acceptable.
17 | */
18 | def autoCull: Boolean = js.native
19 |
20 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Bounds.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package component
3 |
4 | import scala.scalajs.js
5 | import scala.scalajs.js.|
6 |
7 | /**
8 | * The Bounds component contains properties related to the bounds of the Game Object.
9 | * @see http://phaser.io/docs/2.6.2/Phaser.Component.Bounds.html
10 | */
11 | @js.native
12 | //@JSGlobal("Phaser.Component.Bounds")
13 | trait Bounds extends js.Object {
14 |
15 | /////////////////////////////////////////////////////////////////////////////////
16 | // Properties
17 | /////////////////////////////////////////////////////////////////////////////////
18 |
19 | /**
20 | * The sum of the y and height properties.
21 | * This is the same as `y + height - offsetY`.
22 | */
23 | var bottom: Double = js.native
24 |
25 | /**
26 | * The center x coordinate of the Game Object.
27 | * This is the same as `(x - offsetX) + (width / 2)`.
28 | */
29 | var centerX: Double = js.native
30 |
31 | /**
32 | * The center y coordinate of the Game Object.
33 | * This is the same as `(y - offsetY) + (height / 2)`.
34 | */
35 | var centerY: Double = js.native
36 |
37 | /**
38 | * The left coordinate of the Game Object.
39 | * This is the same as `x - offsetX`.
40 | */
41 | var left: Double = js.native
42 |
43 | /**
44 | * The amount the Game Object is visually offset from its x coordinate.
45 | * This is the same as width * anchor.x.
46 | * It will only be > 0 if anchor.x is not equal to zero.
47 | */
48 | def offsetX: Double = js.native
49 |
50 | /**
51 | * The amount the Game Object is visually offset from its y coordinate.
52 | * This is the same as height * anchor.y.
53 | * It will only be > 0 if anchor.y is not equal to zero.
54 | */
55 | def offsetY: Double = js.native
56 |
57 | /**
58 | * The right coordinate of the Game Object.
59 | * This is the same as `x + width - offsetX`.
60 | */
61 | var right: Double = js.native
62 |
63 | /**
64 | * The y coordinate of the Game Object.
65 | * This is the same as `y - offsetY`.
66 | */
67 | var top: Double = js.native
68 |
69 | /////////////////////////////////////////////////////////////////////////////////
70 | // Methods
71 | /////////////////////////////////////////////////////////////////////////////////
72 |
73 | /**
74 | * Aligns this Game Object to the side of another Game Object, or Rectangle, known as the
75 | * 'parent', in one of 11 possible positions.
76 | * The parent must be a Game Object, or Phaser.Rectangle object. This can include properties
77 | * such as World.bounds or Camera.view, for aligning Game Objects within the world
78 | * and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText,
79 | * TileSprites or Buttons.
80 | * Please note that aligning a Sprite to another Game Object does not make it a child of
81 | * the parent. It simply modifies its position coordinates so it aligns with it.
82 | * @param container The Game Object or Rectangle with which to align this Game Object to. Can also include
83 | * properties such as World.bounds or Camera.view
84 | * @param position The position constant. One of Phaser.TOP_LEFT (default), Phaser.TOP_CENTER, Phaser.TOP_RIGHT,
85 | * Phaser.LEFT_CENTER, Phaser.CENTER, Phaser.RIGHT_CENTER, Phaser.BOTTOM_LEFT, Phaser.BOTTOM_CENTER
86 | * or Phaser.BOTTOM_RIGHT
87 | * @param offsetX A horizontal adjustment of the Containers bounds, applied to the aligned position of the
88 | * Game Object. Use a negative value to shrink the bounds, positive to increase it.
89 | * @param offsetY A vertical adjustment of the Containers bounds, applied to the aligned position of the
90 | * Game Object. Use a negative value to shrink the bounds, positive to increase it.
91 | * @return This Game Object.
92 | */
93 | def alignIn(container: Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite,
94 | position: Int = js.native,
95 | offsetX: Double = js.native,
96 | offsetY: Double = js.native): js.Object = js.native
97 |
98 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/BringToTop.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.BringToTop")
8 | trait BringToTop extends js.Object
9 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Core.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package component
3 |
4 | import scala.scalajs.js
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.Core")
8 | trait Core extends js.Object {
9 |
10 | /**
11 | * If the Game Object is enabled for animation (such as a Phaser.Sprite) this is a reference to its AnimationManager instance.
12 | * Through it you can create, play, pause and stop animations.
13 | */
14 | var animations: Phaser.AnimationManager = js.native
15 |
16 | /**
17 | * An empty Object that belongs to this Game Object.
18 | * This value isn't ever used internally by Phaser, but may be used by your own code, or
19 | * by Phaser Plugins, to store data that needs to be associated with the Game Object,
20 | * without polluting the Game Object directly.
21 | */
22 | var data: js.Object = js.native
23 |
24 | /**
25 | * A debug flag designed for use with `Game.enableStep`.
26 | */
27 | var debug: Boolean = js.native
28 |
29 | var events: Phaser.Events = js.native
30 |
31 | /**
32 | * The world coordinates of this Game Object in pixels.
33 | * Depending on where in the display list this Game Object is placed this value can differ from `position`,
34 | * which contains the x/y coordinates relative to the Game Objects parent.
35 | */
36 | var world: Phaser.Point = js.native
37 |
38 | /**
39 | * The z depth of this Game Object within its parent Group.
40 | * No two objects in a Group can have the same z value.
41 | * This value is adjusted automatically whenever the Group hierarchy changes.
42 | * If you wish to re-order the layering of a Game Object then see methods like Group.moveUp or Group.bringToTop.
43 | */
44 | var z: Double = js.native
45 |
46 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Crop.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.Crop")
8 | trait Crop extends js.Object
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Delta.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * The Delta component provides access to delta values between the Game Objects current and previous position.
7 | * @see http://phaser.io/docs/2.6.2/Phaser.Component.Delta.html
8 | */
9 | @js.native
10 | //@JSGlobal("Phaser.Component.Delta")
11 | trait Delta extends js.Object {
12 |
13 | /**
14 | * Returns the delta x value. The difference between world.x now and in the previous frame.
15 | * The value will be positive if the Game Object has moved to the right or negative if to the left.
16 | */
17 | def deltaX: Double = js.native
18 |
19 | /**
20 | * Returns the delta y value. The difference between world.y now and in the previous frame.
21 | * The value will be positive if the Game Object has moved down or negative if up.
22 | */
23 | def deltaY: Double = js.native
24 |
25 | /**
26 | * Returns the delta z value. The difference between rotation now and in the previous frame. The delta value.
27 | */
28 | def deltaZ: Double = js.native
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Destroy.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * The Destroy component is responsible for destroying a Game Object.
7 | * @see http://phaser.io/docs/2.6.2/Phaser.Component.Destroy.html
8 | */
9 | @js.native
10 | //@JSGlobal("Phaser.Component.Destroy")
11 | trait Destroy extends js.Object {
12 |
13 | /////////////////////////////////////////////////////////////////////////////////
14 | // Properties
15 | /////////////////////////////////////////////////////////////////////////////////
16 |
17 | /**
18 | * As a Game Object runs through its destroy method this flag is set to true,
19 | * and can be checked in any sub-systems or plugins it is being destr
20 | */
21 | def destroyPhase: Boolean = js.native
22 |
23 | /////////////////////////////////////////////////////////////////////////////////
24 | // Methods
25 | /////////////////////////////////////////////////////////////////////////////////
26 |
27 | /**
28 | * Destroys the Game Object. This removes it from its parent group, destroys the input, event
29 | * and animation handlers if present and nulls its reference to game, freeing it up for garbage collection.
30 | *
31 | * If this Game Object has the Events component it will also dispatch the onDestroy event.
32 | * You can optionally also destroy the BaseTexture this Game Object is using. Be careful if you've
33 | * more than one Game Object sharing the same BaseTexture.
34 | * @param destroyChildren Should every child of this object have its destroy method called as well?
35 | * @param destroyTexture Destroy the BaseTexture this Game Object is using? Note that if another Game
36 | * Object is sharing the same BaseTexture it will invalidate it.
37 | */
38 | def destroy(destroyChildren: Boolean, destroyTexture: Boolean): Unit = js.native
39 |
40 | def destroy(destroyChildren: Boolean): Unit = js.native
41 |
42 | def destroy(): Unit = js.native
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/FixedToCamera.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.FixedToCamera")
8 | trait FixedToCamera extends js.Object
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Health.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.Health")
8 | trait Health extends js.Object
9 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/InCamera.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.InCamera")
8 | trait InCamera extends js.Object
9 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/InWorld.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.InWorld")
8 | trait InWorld extends js.Object
9 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/InputEnabled.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.InputEnabled")
8 | trait InputEnabled extends js.Object
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/LifeSpan.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import io.scalajs.dom.html.phaser.Phaser
4 | import io.scalajs.dom.html.pixijs.DisplayObject
5 |
6 | import scala.scalajs.js
7 |
8 | @js.native
9 | //@JSGlobal("Phaser.Component.LifeSpan")
10 | trait LifeSpan extends js.Object {
11 |
12 | /**
13 | * A useful flag to control if the Game Object is alive or dead.
14 | *
15 | * This is set automatically by the Health components damage method should the object run out of health.
16 | * Or you can toggle it via your game code.
17 | *
18 | * This property is mostly just provided to be used by your game - it doesn't effect rendering or logic updates.
19 | * However you can use Group.getFirstAlive in conjunction with this property for fast object pooling and recycling.
20 | * @see [[Phaser.Component.LifeSpan#alive]]
21 | */
22 | var alive: Boolean = js.native
23 |
24 | def kill(): DisplayObject = js.native
25 |
26 | def revive(health: Double = 1): DisplayObject = js.native
27 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/LoadTexture.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.LoadTexture")
8 | trait LoadTexture extends js.Object
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Overlap.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | @js.native
7 | //@JSGlobal("Phaser.Component.Overlap")
8 | trait Overlap extends js.Object
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/PhysicsBody.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package component
3 |
4 | import scala.scalajs.js
5 | import scala.scalajs.js.annotation.JSGlobal
6 |
7 | /**
8 | * The PhysicsBody component manages the Game Objects physics body and physics enabling.
9 | * It also overrides the x and y properties, ensuring that any manual adjustment of them
10 | * is reflected in the physics body itself.
11 | * @see https://phaser.io/docs/2.6.2/Phaser.Component.PhysicsBody.html
12 | */
13 | @js.native
14 | //@JSGlobal("Phaser.Component.PhysicsBody")
15 | trait PhysicsBody extends js.Object {
16 |
17 | /**
18 | * body is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated
19 | * properties and methods via it.
20 | *
21 | * By default Game Objects won't add themselves to any physics system and their body property will be null.
22 | *
23 | * To enable this Game Object for physics you need to call game.physics.enable(object, system) where object is this object
24 | * and system is the Physics system you are using. If none is given it defaults to Phaser.Physics.Arcade.
25 | *
26 | * You can alternatively call game.physics.arcade.enable(object), or add this Game Object to a physics enabled Group.
27 | *
28 | * Important: Enabling a Game Object for P2 or Ninja physics will automatically set its anchor property to 0.5,
29 | * so the physics body is centered on the Game Object.
30 | *
31 | * If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor
32 | * after enabling physics.
33 | */
34 | var body: Phaser.Physics.Arcade.Body /*| Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body*/ = js.native
35 |
36 | /**
37 | * The position of the Game Object on the x axis relative to the local coordinates of the parent.
38 | */
39 | def x: Double = js.native
40 |
41 | def x_=(x: Double): Unit = js.native
42 |
43 | /**
44 | * The position of the Game Object on the y axis relative to the local coordinates of the parent.
45 | */
46 | def y: Double = js.native
47 |
48 | def y_=(y: Double): Unit = js.native
49 |
50 | }
51 |
52 | @js.native
53 | @JSGlobal("Phaser.Component.PhysicsBody")
54 | object PhysicsBody extends js.Object {
55 |
56 | /**
57 | * The PhysicsBody component postUpdate handler.
58 | * Called automatically by the Game Object.
59 | */
60 | def postUpdate(): Unit = js.native
61 |
62 | /**
63 | * The PhysicsBody component preUpdate handler.
64 | * Called automatically by the Game Object.
65 | */
66 | def preUpdate(): Unit = js.native
67 |
68 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Reset.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import io.scalajs.dom.html.pixijs.DisplayObject
4 |
5 | import scala.scalajs.js
6 | import scala.scalajs.js.annotation.JSGlobal
7 |
8 | @js.native
9 | //@JSGlobal("Phaser.Component.Reset")
10 | trait Reset extends js.Object {
11 |
12 | def reset(x: Double, y: Double, health: Double = 1): DisplayObject = js.native
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/ScaleMinMax.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import io.scalajs.dom.html.phaser.Phaser
4 |
5 | import scala.scalajs.js
6 |
7 | /**
8 | * The ScaleMinMax component allows a Game Object to limit how far it can be scaled by its parent.
9 | * @see http://phaser.io/docs/2.6.2/Phaser.Component.ScaleMinMax.html#scaleMax
10 | */
11 | @js.native
12 | trait ScaleMinMax extends js.Object {
13 |
14 | /////////////////////////////////////////////////////////////////////////////////
15 | // Properties
16 | /////////////////////////////////////////////////////////////////////////////////
17 |
18 | /**
19 | * The maximum scale this Game Object will scale up to.
20 | *
21 | * It allows you to prevent a parent from scaling this Game Object higher than the given value.
22 | *
23 | * Set it to null to remove the limit.
24 | */
25 | var scaleMax: Phaser.Point = js.native
26 |
27 | /**
28 | * The minimum scale this Game Object will scale down to.
29 | *
30 | * It allows you to prevent a parent from scaling this Game Object lower than the given value.
31 | *
32 | * Set it to null to remove the limit.
33 | */
34 | var scaleMin: Phaser.Point = js.native
35 |
36 | /**
37 | * The callback that will apply any scale limiting to the worldTransform.
38 | */
39 | var transformCallback: js.Function = js.native
40 |
41 | /**
42 | * The context under which `transformCallback` is called.
43 | */
44 | var transformCallbackContext: js.Object = js.native
45 |
46 | /////////////////////////////////////////////////////////////////////////////////
47 | // Methods
48 | /////////////////////////////////////////////////////////////////////////////////
49 |
50 | /**
51 | * Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent.
52 | * For example if this Game Object has a minScale value of 1 and its parent has a scale value of 0.5, the 0.5 will be ignored
53 | * and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to.
54 | * By setting these values you can carefully control how Game Objects deal with responsive scaling.
55 | * If only one parameter is given then that value will be used for both scaleMin and scaleMax:
56 | * setScaleMinMax(1) = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1
57 | * If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y:
58 | * setScaleMinMax(0.5, 2) = scaleMin.x and y = 0.5 and scaleMax.x and y = 2
59 | * If you wish to set scaleMin with different values for x and y then either modify Game Object.scaleMin directly,
60 | * or pass null for the maxX and maxY parameters.
61 | * Call setScaleMinMax(null) to clear all previously set values.
62 | * @param minX The minimum horizontal scale value this Game Object can scale down to.
63 | * @param minY The minimum vertical scale value this Game Object can scale down to.
64 | * @param maxX The maximum horizontal scale value this Game Object can scale up to.
65 | * @param maxY The maximum vertical scale value this Game Object can scale up to.
66 | */
67 | def setScaleMinMax(minX: Double = js.native, minY: Double = js.native, maxX: Double = js.native, maxY: Double = js.native): Unit = js.native
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/component/Smoothed.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.component
2 |
3 | import scala.scalajs.js
4 |
5 | @js.native
6 | //@JSGlobal("Phaser.Component.Smoothed")
7 | trait Smoothed extends js.Object {
8 |
9 | /**
10 | * Enable or disable texture smoothing for this Game Object.
11 | * It only takes effect if the Game Object is using an image based texture.
12 | * Smoothing is enabled by default.
13 | */
14 | var smoothed: Boolean = js.native
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/package.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html
2 |
3 | import io.scalajs.RawOptions
4 |
5 | import scala.scalajs.js
6 | import scala.scalajs.js.Array
7 |
8 | /**
9 | * phaser package object
10 | * @author lawrence.daniels@gmail.com
11 | */
12 | package object phaser {
13 |
14 | type ButtonCode = Int
15 |
16 | /**
17 | * Group Extensions
18 | * @author lawrence.daniels@gmail.com
19 | */
20 | final implicit class GroupExtensions[T](val group: Group[T]) extends AnyVal {
21 |
22 | /**
23 | * Retrieves an array of all living entities
24 | * @param context the given callback context
25 | * @return the array of all living entities
26 | */
27 | @inline
28 | def findAlive(context: RawOptions = group): Array[T] = {
29 | val items = js.Array[T]()
30 | group.foreachAlive(items.append(_), context)
31 | items
32 | }
33 |
34 | @inline
35 | def foreach(callback: T => Any, context: RawOptions = group): Unit = group.forEach(callback, context)
36 |
37 | @inline
38 | def foreachAlive(callback: T => Any, context: RawOptions = group): Unit = group.forEachAlive(callback, context)
39 |
40 | @inline
41 | def foreachDead(callback: T => Any, context: RawOptions = group): Unit = group.forEachDead(callback, context)
42 |
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/Arcade.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package physics
3 |
4 | import io.scalajs.dom.html.pixijs.DisplayObject
5 |
6 | import scala.scalajs.js
7 | import scala.scalajs.js.annotation.JSGlobal
8 | import scala.scalajs.js.|
9 |
10 | /**
11 | * The Arcade Physics world. Contains Arcade Physics related collision, overlap and motion methods.
12 | * @param game reference to the current game instance.
13 | * @see http://phaser.io/docs/2.6.2/Phaser.Physics.Arcade.html
14 | * @author lawrence.daniels@gmail.com
15 | */
16 | @js.native
17 | @JSGlobal("Phaser.Physics.Arcade")
18 | class Arcade(var game: Phaser.Game) extends js.Object {
19 |
20 | /////////////////////////////////////////////////////////////////////////////////
21 | // Properties
22 | /////////////////////////////////////////////////////////////////////////////////
23 |
24 | /**
25 | * The bounds inside of which the physics world exists. Defaults to match the world bounds.
26 | */
27 | var bounds: Phaser.Rectangle = js.native
28 |
29 | /**
30 | * Set the checkCollision properties to control for which bounds collision is processed.
31 | * For example checkCollision.down = false means Bodies cannot collide with the World.bounds.bottom.
32 | * An object containing allowed collision flags.
33 | */
34 | var checkCollision: js.Any = js.native
35 |
36 | /**
37 | * If true World.separate will always separate on the X axis before Y. Otherwise it will check gravity totals first.
38 | */
39 | var forceX: Boolean = js.native
40 |
41 | /**
42 | * The World gravity setting. Defaults to x: 0, y: 0, or no gravity.
43 | */
44 | var gravity: Phaser.Point = js.native
45 |
46 | /**
47 | * If `true` the `Body.preUpdate` method will be skipped, halting all motion for all bodies.
48 | * Note that other methods such as `collide` will still work, so be careful not to call them on paused bodies.
49 | */
50 | var isPaused: Boolean = js.native
51 |
52 | /**
53 | * Used by the QuadTree to set the maximum number of iteration levels.
54 | */
55 | var maxLevels: Double = js.native
56 |
57 | /**
58 | * Used by the QuadTree to set the maximum number of objects per quad.
59 | */
60 | var maxObjects: Double = js.native
61 |
62 | /**
63 | * A value added to the delta values during collision checks.
64 | */
65 | var OVERLAP_BIAS: Double = js.native
66 |
67 | /**
68 | * The world QuadTree.
69 | */
70 | var quadTree: Phaser.QuadTree = js.native
71 |
72 | /**
73 | * If true the QuadTree will not be used for any collision. QuadTrees are great if objects are well spread out
74 | * in your game, otherwise they are a performance hit. If you enable this you can disable on a per body basis
75 | * via Body.skipQuadTree.
76 | */
77 | var skipQuadTree: Boolean = js.native
78 |
79 | /**
80 | * Used when colliding a Sprite vs. a Group, or a Group vs. a Group, this defines the direction the sort is based on.
81 | * Default is Phaser.Physics.Arcade.LEFT_RIGHT.
82 | */
83 | var sortDirection: Int = js.native
84 |
85 | /////////////////////////////////////////////////////////////////////////////////
86 | // Methods
87 | /////////////////////////////////////////////////////////////////////////////////
88 |
89 | /**
90 | * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed
91 | * (in pixels per second sq.)
92 | *
93 | * You must give a maximum speed value, beyond which the display object won't go any faster.
94 | *
95 | * Note: The display object does not continuously track the target. If the target changes location during transit
96 | * the display object will not modify its course.
97 | *
98 | * Note: The display object doesn't stop moving once it reaches the destination coordinates.
99 | * @param displayObject The display object to move.
100 | * @param destination The display object to move towards. Can be any object but must have visible x/y properties.
101 | * @param speed The speed it will accelerate in pixels per second.
102 | * @param xSpeedMax The maximum x velocity the display object can reach.
103 | * @param ySpeedMax The maximum y velocity the display object can reach.
104 | * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory.
105 | */
106 | def accelerateToObject(displayObject: DisplayObject, destination: js.Any, speed: Double, xSpeedMax: Double, ySpeedMax: Double): Double = js.native
107 |
108 | /**
109 | * Sets the acceleration.x/y property on the display object so it will move towards the target
110 | * at the given speed (in pixels per second sq.)
111 | *
112 | * You must give a maximum speed value, beyond which the display object won't go any faster.
113 | * Note: The display object does not continuously track the target. If the target changes location
114 | * during transit the display object will not modify its course.
115 | *
116 | * Note: The display object doesn't stop moving once it reaches the destination coordinates.
117 | * @param displayObject The display object to move.
118 | * @param pointer The pointer to move towards. Defaults to `Phaser.Input.activePointer`.
119 | * @param speed The speed it will accelerate in pixels per second.
120 | * @param xSpeedMax The maximum x velocity the display object can reach.
121 | * @param ySpeedMax The maximum y velocity the display object can reach.
122 | * @return The angle (in radians) that the object should be visually set to in order to match its new trajectory.
123 | */
124 | def accelerateToPointer(displayObject: DisplayObject,
125 | pointer: Phaser.Pointer = js.native,
126 | speed: Double = js.native,
127 | xSpeedMax: Double = js.native,
128 | ySpeedMax: Double = js.native): Double = js.native
129 |
130 | def moveToObject(displayObject: DisplayObject, destination: Any, speed: Int = 60, maxTime: Long = 0): Double = js.native
131 |
132 | def overlap(object1: Sprite | Group[_] | js.Array[_],
133 | object2: Sprite | Group[_] | js.Array[_],
134 | overlapCallback: js.Function2[_, _, _],
135 | processCallback: Option[js.Function2[_, _, Boolean]],
136 | callbackContext: Any = js.native): Unit = js.native
137 |
138 | }
139 |
140 | /**
141 | * Arcade Singleton
142 | * @author lawrence.daniels@gmail.com
143 | */
144 | @js.native
145 | @JSGlobal("Phaser.Physics.Arcade")
146 | object Arcade extends js.Object {
147 |
148 | /**
149 | * A constant used for the sortDirection value. Use this if your game world is narrow but tall and scrolls
150 | * from the bottom to the top (i.e. Commando or a vertically scrolling shoot-em-up)
151 | */
152 | val BOTTOM_TOP: Double = js.native
153 |
154 | /**
155 | * A constant used for the sortDirection value.
156 | * Use this if your game world is wide but short and scrolls from the left to the right (i.e. Mario)
157 | */
158 | val LEFT_RIGHT: Double = js.native
159 |
160 | /**
161 | * A constant used for the sortDirection value.
162 | * Use this if your game world is wide but short and scrolls from the right to the left (i.e. Mario backwards)
163 | */
164 | val RIGHT_LEFT: Double = js.native
165 |
166 | /**
167 | * A constant used for the sortDirection value.
168 | * Use this if you don't wish to perform any pre-collision sorting at all, or will manually sort your Groups.
169 | */
170 | val SORT_NONE: Double = js.native
171 |
172 | /**
173 | * A constant used for the sortDirection value.
174 | * Use this if your game world is narrow but tall and scrolls from the top to the bottom (i.e. Dig Dug)
175 | */
176 | val TOP_BOTTOM: Double = js.native
177 |
178 | }
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/Box2D.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.physics
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * Box2D
7 | */
8 | @js.native
9 | class Box2D extends js.Object {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/Chipmunk.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.physics
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * Chipmunk
7 | */
8 | @js.native
9 | class Chipmunk extends js.Object {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/Matter.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.physics
2 |
3 | import scala.scalajs.js
4 |
5 | /**
6 | * Matter
7 | */
8 | @js.native
9 | class Matter extends js.Object {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/Ninja.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package physics
3 |
4 | import scala.scalajs.js
5 | import scala.scalajs.js.annotation.JSGlobal
6 | import scala.scalajs.js.|
7 |
8 | /**
9 | * Ninja Physics. The Ninja Physics system was created in Flash by Metanet Software
10 | * and ported to JavaScript by Richard Davey.
11 | *
12 | * It allows for AABB and Circle to Tile collision. Tiles can be any of 34 different types,
13 | * including slopes, convex and concave shapes.
14 | * *
15 | * It does what it does very well, but is ripe for expansion and optimisation. Here are some
16 | * features that I'd love to see the community add:
17 | *
18 | * - AABB to AABB collision
19 | * - AABB to Circle collision
20 | * - AABB and Circle 'immovable' property support
21 | * - n-way collision, so an AABB/Circle could pass through a tile from below and land upon it.
22 | * - QuadTree or spatial grid for faster Body vs. Tile Group look-ups.
23 | * - Optimise the internal vector math and reduce the quantity of temporary vars created.
24 | * - Expand Gravity and Bounce to allow for separate x/y axis values.
25 | * - Support Bodies linked to Sprites that don't have anchor set to 0.5
26 | *
27 | * Feel free to attempt any of the above and submit a Pull Request with your code! Be sure
28 | * to include test cases proving they work.
29 | * @see http://phaser.io/docs/2.6.2/Phaser.Physics.Ninja.html
30 | */
31 | @js.native
32 | @JSGlobal("Phaser.Physics.Ninja")
33 | class Ninja(var game: Phaser.Game) extends js.Object {
34 |
35 | /////////////////////////////////////////////////////////////////////////////////
36 | // Properties
37 | /////////////////////////////////////////////////////////////////////////////////
38 |
39 | /**
40 | * The bounds inside of which the physics world exists. Defaults to match the world bounds.
41 | */
42 | var bounds: Phaser.Rectangle = js.native
43 |
44 | /**
45 | * The World gravity setting.
46 | */
47 | var gravity: Double = js.native
48 |
49 | /**
50 | * Used by the QuadTree to set the maximum number of iteration levels.
51 | */
52 | var maxLevels: Int = js.native
53 |
54 | /**
55 | * Used by the QuadTree to set the maximum number of objects per quad.
56 | */
57 | var maxObjects: Int = js.native
58 |
59 | /**
60 | * The world QuadTree.
61 | */
62 | var quadTree: Phaser.QuadTree = js.native
63 |
64 | /**
65 | * Local reference to game.time.
66 | */
67 | var time: Phaser.Time = js.native
68 |
69 | /////////////////////////////////////////////////////////////////////////////////
70 | // Methods
71 | /////////////////////////////////////////////////////////////////////////////////
72 |
73 | /**
74 | *
75 | * @param map
76 | * @param layer
77 | */
78 | def clearTilemapLayerBodies(map: Phaser.Tilemap, layer: Double | String | Phaser.TilemapLayer): Unit = js.native
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/P2.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package physics
3 |
4 | import io.scalajs.RawOptions
5 |
6 | import scala.scalajs.js
7 | import scala.scalajs.js.annotation.JSGlobal
8 |
9 | /**
10 | * This is your main access to the P2 Physics World. From here you can create materials, listen for events and add bodies
11 | * into the physics simulation.
12 | * @param game Reference to the current game instance.
13 | * @param config Physics configuration object passed in from the game constructor.
14 | */
15 | @js.native
16 | @JSGlobal("Phaser.Physics.P2")
17 | class P2(var game: Phaser.Game, val config: RawOptions = js.native) extends js.Object {
18 |
19 | /**
20 | * Enable to automatically apply body damping each step.
21 | */
22 | var applyDamping: Boolean = js.native
23 |
24 | /**
25 | * TODO
26 | */
27 | var allowSleep: Boolean = js.native
28 |
29 | /**
30 | * The angle of the Body in degrees from its original orientation. Values from 0 to 180 represent clockwise rotation;
31 | * values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted
32 | * from 360 to obtain a value within the range. For example, the statement Body.angle = 450 is the same as
33 | * Body.angle = 90. If you wish to work in radians instead of degrees use the property Body.rotation instead.
34 | * Working in radians is faster as it doesn't have to convert values. The angle of this Body in degrees.
35 | */
36 | var angle: Double = js.native
37 |
38 | /**
39 | * Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. The angular
40 | * damping acting acting on the body.
41 | */
42 | var angularDamping: Double = js.native
43 |
44 | /**
45 | * The angular force acting on the body.
46 | */
47 | var angularForce: Double = js.native
48 |
49 | /**
50 | * The angular velocity of the body.
51 | */
52 | var angularVelocity: Double = js.native
53 |
54 | /**
55 | * A Body can be set to collide against the World bounds automatically if this is set to true. Otherwise it will
56 | * leave the World. Note that this only applies if your World has bounds! The response to the collision should be
57 | * managed via CollisionMaterials. Also note that when you set this it will only effect Body shapes that already
58 | * exist. If you then add further shapes to your Body after setting this it will not proactively set them to collide
59 | * with the bounds. Should the Body collide with the World bounds?
60 | */
61 | var collidesWith: js.Array[_] = js.native
62 |
63 | /**
64 | * Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. The linear
65 | * damping acting on the body in the velocity direction.
66 | */
67 | var damping: Double = js.native
68 |
69 | /**
70 | * The p2 Body data.
71 | * Internal: This member is internal (protected) and may be modified or removed in the future.
72 | */
73 | var data: P2.Body = js.native
74 |
75 | /**
76 | * Enable or disable debug drawing of this body
77 | */
78 | var debug: Boolean = js.native
79 |
80 | /**
81 | * Reference to the debug body.
82 | */
83 | var debugBody: /*Phaser.Physics.*/ P2.BodyDebug = js.native
84 |
85 | /**
86 | * Internally used by Sprite.x/y
87 | */
88 | var dirty: Boolean = js.native
89 |
90 | }
91 |
92 | @js.native
93 | @JSGlobal("P2")
94 | object P2 extends js.Object {
95 |
96 | /**
97 | * The Physics Body is typically linked to a single Sprite and defines properties that determine how the physics body
98 | * is simulated. These properties affect how the body reacts to forces, what forces it generates on itself (to simulate
99 | * friction), and how it reacts to collisions in the scene. In most cases, the properties are used to simulate physical
100 | * effects. Each body also has its own property values that determine exactly how it reacts to forces and collisions
101 | * in the scene. By default a single Rectangle shape is added to the Body that matches the dimensions of the parent
102 | * Sprite. See addShape, removeShape, clearShapes to add extra shapes around the Body. Note: When bound to a Sprite
103 | * to avoid single-pixel jitters on mobile devices we strongly recommend using Sprite sizes that are even on both
104 | * axis, i.e. 128x128 not 127x127. Note: When a game object is given a P2 body it has its anchor x/y set to 0.5,
105 | * so it becomes centered.
106 | * @param game Game reference to the currently running game.
107 | * @param sprite The Sprite object this physics body belongs to.
108 | * @param x The x coordinate of this Body.
109 | * @param y The y coordinate of this Body.
110 | * @param mass The default mass of this Body (0 = static).
111 | */
112 | @js.native
113 | class Body(var game: Phaser.Game,
114 | val sprite: Sprite,
115 | val x: Int = js.native,
116 | val y: Int = js.native,
117 | val mass: Int = js.native)
118 | extends js.Object
119 |
120 | @js.native
121 | object Body extends js.Object {
122 |
123 | /**
124 | * Dynamic body. Dynamic bodies body can move and respond to collisions and forces.
125 | */
126 | def DYNAMIC: Int = js.native
127 |
128 | /**
129 | * Kinematic body. Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force.
130 | */
131 | def KINEMATIC: Int = js.native
132 |
133 | /**
134 | * Static body. Static bodies do not move, and they do not respond to forces or collision.
135 | */
136 | def STATIC: Int = js.native
137 |
138 | }
139 |
140 | /**
141 | * Draws a P2 Body to a Graphics instance for visual debugging. Needless to say, for every body you enable debug
142 | * drawing on, you are adding processor and graphical overhead. So use sparingly and rarely (if ever) in production code.
143 | *
144 | * Also be aware that the Debug body is only updated when the Sprite it is connected to changes position. If you
145 | * manipulate the sprite in any other way (such as moving it to another Group or bringToTop, etc) then you will need
146 | * to manually adjust its BodyDebug as well.
147 | * @param game Game reference to the currently running game.
148 | * @param body The P2 Body to display debug data for.
149 | * @param settings Settings object.
150 | */
151 | @js.native
152 | class BodyDebug(var game: Phaser.Game, val body: /*Phaser.Physics.*/ P2.Body, val settings: js.Any) extends js.Object
153 |
154 | // Phaser.Group(game, )
155 |
156 | @js.native
157 | object BodyDebug extends js.Object
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/ninja/AABB.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser
2 | package physics.ninja
3 |
4 | import scala.scalajs.js
5 | import scala.scalajs.js.annotation.JSGlobal
6 |
7 | /**
8 | * Ninja Physics AABB constructor.
9 | * Note: This class could be massively optimised and reduced in size. I leave that challenge up to you.
10 | * @param body The body that owns this shape.
11 | * @param x The x coordinate to create this shape at.
12 | * @param y The y coordinate to create this shape at.
13 | * @param width The width of this AABB.
14 | * @param height The height of this AABB.
15 | */
16 | @js.native
17 | @JSGlobal("Phaser.Physics.Ninja.AABB")
18 | class AABB(var body: Phaser.Physics.Ninja.Body,
19 | var x: Double,
20 | var y: Double,
21 | var width: Double,
22 | var height: Double)
23 | extends js.Object {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/ninja/Body.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.physics.ninja
2 |
3 | import io.scalajs.dom.html.phaser.Phaser
4 |
5 | import scala.scalajs.js
6 | import scala.scalajs.js.annotation.JSGlobal
7 |
8 | /**
9 | * The Physics Body is linked to a single Sprite. All physics operations should be performed
10 | * against the body rather than the Sprite itself. For example you can set the velocity,
11 | * bounce values etc all on the Body.
12 | * @param system The physics system this Body belongs to.
13 | * @param sprite The Sprite object this physics body belongs to.
14 | * @param `type` The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.
15 | * @param id If this body is using a Tile shape, you can set the Tile id here,
16 | * i.e. Phaser.Physics.Ninja.Tile.SLOPE_45DEGpn, Phaser.Physics.Ninja.Tile.CONVEXpp, etc.
17 | * @param radius If this body is using a Circle shape this controls the radius.
18 | * @param x The x coordinate of this Body. This is only used if a sprite is not provided.
19 | * @param y The y coordinate of this Body. This is only used if a sprite is not provided.
20 | * @param width The width of this Body. This is only used if a sprite is not provided.
21 | * @param height The height of this Body. This is only used if a sprite is not provided.
22 | * @see http://phaser.io/docs/2.6.2/Phaser.Physics.Ninja.Body.html
23 | */
24 | @js.native
25 | @JSGlobal("Phaser.Physics.Ninja.Body")
26 | class Body(var system: Phaser.Physics.Ninja,
27 | var sprite: Phaser.Sprite,
28 | var `type`: Int = js.native,
29 | var id: Int = js.native,
30 | var radius: Double = js.native,
31 | var x: Double = js.native,
32 | var y: Double = js.native,
33 | var width: Double = js.native,
34 | var height: Double = js.native)
35 | extends js.Object {
36 |
37 | /////////////////////////////////////////////////////////////////////////////////
38 | // Properties
39 | /////////////////////////////////////////////////////////////////////////////////
40 |
41 | /**
42 | * The AABB object this body is using for collision.
43 | */
44 | var aabb: Phaser.Physics.Ninja.AABB = js.native
45 |
46 | /**
47 | * The angle of this Body
48 | */
49 | def angle: Double = js.native
50 |
51 | /**
52 | * The bottom value of this Body (same as Body.y + Body.height)
53 | */
54 | var bottom: Double = js.native
55 |
56 | /**
57 | * The bounciness of this object when it collides. A value between 0 and 1.
58 | * We recommend setting it to 0.999 to avoid jittering.
59 | */
60 | var bounce: Double = js.native
61 |
62 | /**
63 | * Set the checkCollision properties to control which directions collision is processed for this Body.
64 | * For example checkCollision.up = false means it won't collide when the collision happened while moving up.
65 | * An object containing allowed collision.
66 | */
67 | var checkCollision: js.Object = js.native
68 |
69 | /////////////////////////////////////////////////////////////////////////////////
70 | // Methods
71 | /////////////////////////////////////////////////////////////////////////////////
72 |
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/physics/p2/Material.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.physics.p2
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | /**
7 | * A P2 Material.
8 | * @param name The user defined name given to this Material.
9 | * @see http://phaser.io/docs/2.6.2/Phaser.Physics.P2.Material.html
10 | */
11 | @js.native
12 | @JSGlobal("Phaser.Physics.P2.Material")
13 | class Material(var name: String) extends js.Object
14 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/utils/ArrayUtils.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.utils
2 |
3 | import io.scalajs.JsNumber
4 |
5 | import scala.scalajs.js
6 | import scala.scalajs.js.|
7 |
8 | /**
9 | * Utility functions for dealing with Arrays.
10 | * @see https://phaser.io/docs/2.6.2/Phaser.ArrayUtils.html
11 | * @author lawrence.daniels@gmail.com
12 | */
13 | @js.native
14 | class ArrayUtils extends js.Object {
15 |
16 | /**
17 | * Snaps a value to the nearest value in an array.
18 | * @param value The search value
19 | * @param arr The input array which must be sorted.
20 | * @return The nearest value found.
21 | */
22 | def findClosest(value: JsNumber, arr: js.Array[JsNumber]): Int = js.native
23 |
24 | /**
25 | * Fetch a random entry from the given array.
26 | * Will return null if there are no array items that fall within the specified range or if there is no item
27 | * for the randomly chosen index.
28 | * @param objects An array of objects.
29 | * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
30 | * @param length Optional restriction on the number of values you want to randomly select from.
31 | * @return The random object that was selected.
32 | */
33 | def getRandomItem[T](objects: js.Array[T], startIndex: Int = js.native, length: Int = js.native): T = js.native
34 |
35 | /**
36 | * Create an array representing the inclusive range of numbers (usually integers) in [start, end].
37 | * This is equivalent to `numberArrayStep(start, end, 1)`.
38 | * @param start The minimum value the array starts with.
39 | * @param end The maximum value the array contains.
40 | * @return The array of number values.
41 | */
42 | def numberArray[T](start: JsNumber, end: JsNumber): js.Array[T] = js.native
43 |
44 | /**
45 | * Create an array of numbers (positive and/or negative) progressing from start
46 | * up to but not including end by advancing by step.
47 | * If start is less than end a zero-length range is created unless a negative step is specified.
48 | * Certain values for start and end (eg. NaN/undefined/null) are currently coerced to 0;
49 | * for forward compatibility make sure to pass in actual numbers.
50 | * @param start The start of the range.
51 | * @param end The end of the range.
52 | * @param step The value to increment or decrement by.
53 | * @return Returns the new array of numbers.
54 | */
55 | def numberArrayStep[T](start: JsNumber, end: JsNumber = js.native, step: Int = js.native): js.Array[T] = js.native
56 |
57 | /**
58 | * Removes a random object from the given array and returns it.
59 | * Will return null if there are no array items that fall within the specified range or if there is no item
60 | * for the randomly chosen index.
61 | * @param objects An array of objects.
62 | * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
63 | * @param length Optional restriction on the number of values you want to randomly select from.
64 | * @return The random object that was removed.
65 | */
66 | def removeRandomItem[T](objects: js.Array[T], startIndex: Int = js.native, length: Int = js.native): T = js.native
67 |
68 | /**
69 | * Moves the element from the start of the array to the end, shifting all items in the process.
70 | * The "rotation" happens to the left.
71 | * @param array The array to rotate. The array is modified.
72 | * @return The rotated value.
73 | */
74 | @deprecated("This method is deprecated and should not be used. It may be removed in the future.", since = "2.6.2")
75 | def rotate[T](array: js.Array[T]): js.Array[T] = js.native
76 |
77 | /**
78 | * Moves the element from the start of the array to the end, shifting all items in the process.
79 | * The "rotation" happens to the left.
80 | * @param array The array to rotate. The array is modified.
81 | * @return The rotated value.
82 | */
83 | def rotateLeft[T](array: js.Array[T]): js.Array[T] = js.native
84 |
85 | /**
86 | * Rotates the given matrix (array of arrays).
87 | * @see http://jsfiddle.net/MrPolywhirl/NH42z/.
88 | * @param matrix The array to rotate; this matrix may be altered.
89 | * @param direction The amount to rotate: the rotation in degrees (90, -90, 270, -270, 180)
90 | * or a string command ('rotateLeft', 'rotateRight' or 'rotate180').
91 | * @return The rotated matrix. The source matrix should be discarded for the returned matrix.
92 | */
93 | def rotateMatrix[T](matrix: js.Array[T], direction: JsNumber | String): js.Array[T] = js.native
94 |
95 | /**
96 | * Moves the element from the end of the array to the start, shifting all items in the process.
97 | * The "rotation" happens to the right.
98 | * @param array The array to rotate. The array is modified.
99 | * @return The shifted value.
100 | */
101 | def rotateRight[T](array: js.Array[T]): js.Array[T] = js.native
102 |
103 | /**
104 | * A standard Fisher-Yates Array shuffle implementation which modifies the array in place.
105 | * @param array The array to shuffle.
106 | * @return The original array, now shuffled.
107 | */
108 | def shuffle[T](array: js.Array[T]): js.Array[T] = js.native
109 |
110 | /**
111 | * Transposes the elements of the given matrix (array of arrays).
112 | * @param array The matrix to transpose.
113 | * @return A new transposed matrix
114 | */
115 | def transposeMatrix[T](array: js.Array[T]): js.Array[T] = js.native
116 |
117 | }
118 |
119 | /**
120 | * Array Utils Singleton
121 | * @author lawrence.daniels@gmail.com
122 | */
123 | @js.native
124 | object ArrayUtils extends ArrayUtils
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/utils/Debug.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.utils
2 |
3 | import scala.scalajs.js
4 | import scala.scalajs.js.annotation.JSGlobal
5 |
6 | /**
7 | * Phaser Utils Debug
8 | * @author lawrence.daniels@gmail.com
9 | */
10 | @js.native
11 | @JSGlobal("Phaser.Utils.Debug")
12 | class Debug extends js.Object
13 |
--------------------------------------------------------------------------------
/src/main/scala/io/scalajs/dom/html/phaser/utils/Utils.scala:
--------------------------------------------------------------------------------
1 | package io.scalajs.dom.html.phaser.utils
2 |
3 | import io.scalajs.JsNumber
4 |
5 | import scala.scalajs.js
6 | import scala.scalajs.js.|
7 |
8 | /**
9 | * Phaser.Utils
10 | * @version 2.6.2
11 | * @see https://phaser.io/docs/2.6.2/Phaser.Utils.html
12 | * @author lawrence.daniels@gmail.com
13 | */
14 | @js.native
15 | class Utils extends js.Object
16 |
17 | /**
18 | * Phaser.Utils Singleton
19 | * @author lawrence.daniels@gmail.com
20 | */
21 | @js.native
22 | object Utils extends js.Object {
23 |
24 | /**
25 | * This is a slightly modified version of http://api.jquery.com/jQuery.extend/
26 | * @param deep Perform a deep copy?
27 | * @param target The target object to copy to.
28 | * @return The extended object.
29 | */
30 | def extend[A](deep: Boolean, target: js.Any): A = js.native
31 |
32 | /**
33 | * Gets an objects property by string.
34 | * @param obj The object to traverse.
35 | * @param prop The property whose value will be returned.
36 | * @return the value of the property or null if property isn"t found.
37 | */
38 | def getProperty(obj: js.Any, prop: String): js.Any = js.native
39 |
40 | /**
41 | * This is a slightly modified version of jQuery.isPlainObject.
42 | * A plain object is an object whose internal class property is [object Object].
43 | * @param obj The object to inspect.
44 | * @return true if the object is plain, otherwise false.
45 | */
46 | def isPlainObject(obj: js.Any): Boolean = js.native
47 |
48 | /**
49 | * Mixes the source object into the destination object, returning the newly modified destination object.
50 | * @param from The object to copy (the source object).
51 | * @param to The object to copy to (the destination object).
52 | * @return The modified destination object.
53 | */
54 | def mixin(from: js.Any, to: js.Any): js.Any = js.native
55 |
56 | /**
57 | * Mixes in an existing mixin object with the target.
58 | * Values in the mixin that have either `get` or `set` functions are created as properties via `defineProperty`
59 | * except if they also define a `clone` method - if a clone method is defined that is called instead and
60 | * the result is assigned directly.
61 | * @param target The target object to receive the new functions.
62 | * @param mixin The object to copy the functions from.
63 | * @param replace If the target object already has a matching function should it be overwritten or not?
64 | * @return
65 | */
66 | def mixinPrototype(target: js.Any, mixin: js.Any, replace: Boolean = js.native): js.Any = js.native
67 |
68 | /**
69 | *
70 | * @param str The target string. toString() will be called on the string, which means you can also pass in
71 | * common data types like numbers.
72 | * @param len The number of characters to be added.
73 | * @param pad The string to pad it out with (defaults to a space).
74 | * @param dir The direction dir = 1 (left), 2 (right), 3 (both).
75 | * @return The padded string.
76 | * @example {{{ pad("bob", 6, "-", 2) }}}
77 | */
78 | def pad(str: js.Any | String, len: Int = js.native, pad: String = js.native, dir: Int = js.native): String =
79 | js.native
80 |
81 | /**
82 | * Get a unit dimension from a string.
83 | * @param size The size to parse.
84 | * @param dimension The window dimension to check.
85 | * @return The parsed dimension.
86 | */
87 | def parseDimension(size: JsNumber | String, dimension: JsNumber): Int = js.native
88 |
89 | /**
90 | * Takes the given string and reverses it, returning the reversed string.
91 | * For example if given the string "Atari 520ST" it would return "TS025 iratA".
92 | * @param string The string to be reversed.
93 | * @return The reversed string.
94 | */
95 | def reverseString(string: String): String = js.native
96 |
97 | /**
98 | * Sets an objects property by string.
99 | * @param obj The object to traverse
100 | * @param prop The property whose value will be changed
101 | * @return The object on which the property was set.
102 | */
103 | def setProperty[T](obj: T, prop: String): T = js.native
104 |
105 | /**
106 | * Generate a random bool result based on the chance value.
107 | * Returns true or false based on the chance value (default 50%).
108 | * For example if you wanted a player to have a 30% chance of getting a bonus, call chanceRoll(30)
109 | * - true means the chance passed,
110 | * - false means it failed.
111 | * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).
112 | * @return True if the roll passed, or false otherwise.
113 | */
114 | def chanceRoll(chance: JsNumber): Boolean = js.native
115 |
116 | /**
117 | * Choose between one of two values randomly.
118 | * @param choice1 the first choice
119 | * @param choice2 the second choice
120 | * @return The randomly selected choice
121 | */
122 | def randomChoice(choice1: js.Any, choice2: js.Any): js.Any = js.native
123 |
124 | }
125 |
--------------------------------------------------------------------------------