Skip to content

Commit

Permalink
Miscellaneous fixes
Browse files Browse the repository at this point in the history
1. Fixed issue with ErrorEvent - message was missing
2. Added missing API methods to various Phaser classes
  • Loading branch information
ldaniels528 committed Feb 4, 2017
1 parent 3b19308 commit 8bfc924
Show file tree
Hide file tree
Showing 46 changed files with 1,702 additions and 152 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ The following applications were developed using ScalaJs.io:

| Application | Frontend | Backend | Scalajs.io version | Description |
|------------------------------------------------------------------------|-----------------------|--------------------|--------------------|------------------------------------------|
| [Scalajs-Invaders](https://github.com/ldaniels528/scalajs-invaders) | Scala.js + DOM | Scala + NodeJS | 0.3.0.0 | Port of Phaser Invaders. |
| [Socialize](https://github.com/ldaniels528/scalajs-nodejs-socialized) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A Facebook-inspired Social networking web application. |
| [Scalajs-Invaders](https://github.com/ldaniels528/scalajs-invaders) | Scala.js + DOM | Scala + NodeJS | 0.3.0.1 | Port of Phaser Invaders. |
| [Socialize](https://github.com/ldaniels528/scalajs-nodejs-socialized) | Scala.js + AngularJS | Scala.js + NodeJS | 0.3.0.3 | A Facebook-inspired Social networking web application. |
| [Todo MVC](https://github.com/ldaniels528/scalajs-nodejs-todomvc) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A simple Todo example application. |
| [Trifecta](https://github.com/ldaniels528/trifecta) | Scala.js + AngularJS | Scala + Play 2.4.x | 0.3.0.0 | Trifecta is a web-based and CLI tool that simplifies inspecting Kafka messages and Zookeeper data. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ import scala.scalajs.js
* being a WebSocket or a WebRTC RTCDataChannel.
*/
@js.native
class ErrorEvent() extends Event {}
class ErrorEvent() extends Event {

def message: String = js.native

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.scalajs.js.annotation.JSName
*/
@js.native
@JSName("Phaser.AudioSprite")
class AudioSprite(val game: Game, val key: String) extends js.Object {
class AudioSprite(var game: Phaser.Game, var key: String) extends js.Object {

/////////////////////////////////////////////////////////////////////////////////
// Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import scala.scalajs.js.annotation.JSName
*/
@js.native
@JSName("Phaser.BitmapText")
class BitmapText(val game: Game,
class BitmapText(var game: Phaser.Game,
override var x: Double,
override var y: Double,
val font: String,
Expand Down Expand Up @@ -62,4 +62,14 @@ class BitmapText(val game: Game,
*/
override var angle: Double = js.native

/**
* Base destroy method for generic display objects.
*/
override def destroy(): Unit = js.native

/**
* Base destroy method for generic display objects.
*/
override def destroy(destroyChildren: Boolean): Unit = js.native

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import scala.scalajs.js.annotation.JSName
*/
@js.native
@JSName("Phaser.Cache")
class Cache(val game: Game) extends js.Object {}
class Cache(var game: Phaser.Game) extends js.Object {}

@js.native
@JSName("Phaser.Cache")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.scalajs.js.annotation.JSName
*/
@js.native
@JSName("Phaser.Camera")
class Camera(val game: Game, val id: Int = 0, var x: Double, var y: Double, var width: Double, var height: Double)
class Camera(var game: Phaser.Game, val id: Int = 0, var x: Double, var y: Double, var width: Double, var height: Double)
extends js.Object {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.scalajs.js.annotation.JSName
*/
@js.native
@JSName("Phaser.GameObjectCreator")
class GameObjectCreator(val game: Game) extends js.Object {
class GameObjectCreator(var game: Phaser.Game) extends js.Object {

/////////////////////////////////////////////////////////////////////////////////
// Properties
Expand Down
171 changes: 171 additions & 0 deletions browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/Gamepad.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package io.scalajs.dom.html.phaser

import io.scalajs.RawOptions

import scala.scalajs.js
import scala.scalajs.js.annotation.{JSName, ScalaJSDefined}

/**
* The Gamepad class handles gamepad input and dispatches gamepad events.
*
* Remember to call gamepad.start().
*
* HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE!
* At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it
* via prefs flags (about:config, search gamepad). The browsers map the same controllers differently.
* This class has constants for Windows 7 Chrome mapping of XBOX 360 controller.
* @see http://phaser.io/docs/2.6.2/Phaser.Gamepad.html
*/
@js.native
@JSName("Phaser.Gamepad")
class Gamepad(var game: Phaser.Game) extends js.Object {

/////////////////////////////////////////////////////////////////////////////////
// Properties
/////////////////////////////////////////////////////////////////////////////////

/**
* If the gamepad input is active or not - if not active it should not be updated from Input.js
*/
def active: Boolean = js.native

/**
* The context under which the callbacks are run.
*/
var callbackContext: js.Object = js.native

/**
* Gamepad input will only be processed if enabled (default: true).
*/
var enabled: Boolean = js.native

/**
* This callback is invoked every time any gamepad axis is changed.
*/
var onAxisCallback: js.Function = js.native

/**
* This callback is invoked every time any gamepad is disconnected
*/
var onConnectCallback: js.Function = js.native

/**
* This callback is invoked every time any gamepad button is pressed down.
*/
var onDownCallback: js.Function = js.native

/**
* This callback is invoked every time any gamepad button is changed to a value where value > 0 and value < 1.
*/
var onFloatCallback: js.Function = js.native

/**
* This callback is invoked every time any gamepad button is released.
*/
var onUpCallback: js.Function = js.native

/**
* Gamepad #1
*/
def pad1: Phaser.SinglePad = js.native

/**
* Gamepad #2
*/
def pad2: Phaser.SinglePad = js.native

/**
* Gamepad #3
*/
def pad3: Phaser.SinglePad = js.native

/**
* Gamepad #4
*/
def pad4: Phaser.SinglePad = js.native

/**
* How many live gamepads are currently connected.
*/
def padsConnected: Int = js.native

/**
* Whether or not gamepads are supported in current browser.
*/
def supported: Boolean = js.native

/////////////////////////////////////////////////////////////////////////////////
// Methods
/////////////////////////////////////////////////////////////////////////////////

/**
* Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button
* up/axis change/float value buttons.
* @param context The context under which the callbacks are run.
* @param callbacks Object that takes six different callback methods:
* onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback,
* onAxisCallback, onFloatCallback
*/
def addCallbacks(context: RawOptions, callbacks: Callbacks): Unit = js.native

/**
* Destroys this object and the associated event listeners.
*/
def destroy(): Unit = js.native

/**
* Returns true if the button is currently pressed down, on ANY gamepad.
* @param buttonCode The buttonCode of the button to check for.
* @return True if a button is currently down.
*/
def isDown(buttonCode: ButtonCode): Boolean = js.native

/**
* Returns the "just released" state of a button from ANY gamepad connected.
* Just released is considered as being true if the button was released within
* the duration given (default 250ms).
* @param buttonCode The buttonCode of the button to check for.
* @param duration The duration below which the button is considered as being just released.
* @return True if the button is just released otherwise false.
*/
def justPressed(buttonCode: ButtonCode, duration: Double = js.native): Boolean = js.native

/**
* Reset all buttons/axes of all gamepads
*/
def reset(): Unit = js.native

/**
* Sets the deadZone variable for all four gamepads
*/
def setDeadZones(): Unit = js.native

/**
* Starts the Gamepad event handling.
* This MUST be called manually before Phaser will start polling the Gamepad API.
*/
def start(): Unit = js.native

/**
* Stops the Gamepad event handling.
*/
def stop(): Unit = js.native

}

/**
* Callbacks Object
* @param onConnectCallback
* @param onDisconnectCallback
* @param onDownCallback
* @param onUpCallback
* @param onAxisCallback
* @param onFloatCallback
*/
@ScalaJSDefined
class Callbacks(var onConnectCallback: js.UndefOr[js.Function] = js.undefined,
var onDisconnectCallback: js.UndefOr[js.Function] = js.undefined,
var onDownCallback: js.UndefOr[js.Function] = js.undefined,
var onUpCallback: js.UndefOr[js.Function] = js.undefined,
var onAxisCallback: js.UndefOr[js.Function] = js.undefined,
var onFloatCallback: js.UndefOr[js.Function] = js.undefined) extends js.Object
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.scalajs.js.annotation.JSName
*/
@js.native
@JSName("Phaser.Graphics")
class Graphics(val game: Phaser.Game,
class Graphics(var game: Phaser.Game,
override var x: Double,
override var y: Double)
extends pixijs.Graphics
Expand All @@ -32,6 +32,27 @@ class Graphics(val game: Phaser.Game,
with Phaser.Component.PhysicsBody
with Phaser.Component.Reset {

/**
* The angle property is the rotation of the Game Object in degrees from its original orientation.
*
* Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
*
* Values outside this range are added to or subtracted from 360 to obtain a value within the range.
* For example, the statement player.angle = 450 is the same as player.angle = 90.
*
* If you wish to work in radians instead of degrees you can use the property rotation instead.
* Working in radians is slightly faster as it doesn't have to perform any calculations.
*/
override var angle: Double = js.native

/**
* Base destroy method for generic display objects.
*/
override def destroy(): Unit = js.native

/**
* Base destroy method for generic display objects.
*/
override def destroy(destroyChildren: Boolean): Unit = js.native

}
Loading

0 comments on commit 8bfc924

Please sign in to comment.