6.1.2 • Published 7 years ago

apex-app v6.1.2

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

apex-app

For creating interactive apps using pixi.js.

Example App

Particle Sandbox
URL: http://particlesandbox.com
GitHub: https://github.com/apexearth/particle-sandbox
App Class: https://github.com/apexearth/particle-sandbox/blob/develop/app/ParticleSandbox.js#L25

Basic Usage

  1. Create an App.
  2. Add AppObjects to it.
  3. Create a renderer for the App.
  4. The renderer starts the update & draw loop, rendering the App.
const {
   App,
   AppObject,
   createRenderer,
   PIXI,
   setting,
   properties,
   property
} = require('apex-app')

// Extend App
// Initialize with a single AppObject drawn as a white square.
class Game extends App {
   constructor() {
       super()
       let obj = new AppObject({parent: this})
       obj.graphics.beginFill(0xffffff, 1)
       obj.graphics.drawRect(0, 0, 10, 10)
       obj.graphics.endFill()
       this.add(obj)
   }
}

// Create renderer and attach canvas to `document.body`.
createRenderer(new Game(), {
   rendererOptions: {
       backgroundColor: 0x333333
   }
})

App

The core app containing the update loop.

Kind: global class

new App(options)

ParamDescription
optionsThe options to use in the App.

app.type : string

The object type. ("app")

Kind: instance property of App

app.objects : Array.<AppObject>

The AppObjects added to the App.

Kind: instance property of App

app.view

View options.

Kind: instance property of App

app.position ⇒ App.container.position | Object

This position {x, y} of the App view.

Kind: instance property of App

app.scale ⇒ App.container.scale | Object

The scale {x, y} of the App view.

Kind: instance property of App

app.targetScale ⇒ Object

The target scale {x, y} of the App view. (zoom target)

Kind: instance property of App

app.screenWidth ⇒ Number

The width of the window.

Kind: instance property of App

app.screenHeight ⇒ Number

The height of the window.

Kind: instance property of App

app.paused ⇒ boolean

Get the app paused value.

Kind: instance property of App

app.paused

Set the app paused value.

Kind: instance property of App

ParamType
valboolean

app.zoom

Get the zoom value.

Kind: instance property of App

app.zoom

Set the zoom value.

Kind: instance property of App

Param
val

app.centerOn(object)

Center on an object in the App.

Kind: instance method of App

Param
object

app.togglePause()

Toggle app paused value.

Kind: instance method of App

app.pauseRendering()

Pause rendering of the app.

Kind: instance method of App

app.resumeRendering()

Resume rendering of the app.

Kind: instance method of App

app.kill()

Kill the app renderer.

Kind: instance method of App

app.translatePosition(position) ⇒ Object

Translate a position from the window into the app.

Kind: instance method of App

Param
position

app.update(seconds)

The main update loop of the app, which is triggered by the renderer.

Kind: instance method of App

ParamType
secondsNumber

app.previewObject(object) ⇒ AppObject

Add an AppObject to the view, but not the game loop.

Kind: instance method of App
Returns: AppObject - - (object)

ParamType
objectAppObject

app.cancelPreview(object) ⇒ AppObject

Remove an AppObject from the view which was added with .previewObject()

Kind: instance method of App
Returns: AppObject - - (object)

ParamType
objectAppObject

app.removeObjects(objects)

Remove an array of AppObjects.

Kind: instance method of App

ParamTypeDescription
objectsArray.<AppObject>An array of AppObjects to remove from the App.

app.contains(object) ⇒ boolean

Check if the App contains an AppObject.

Kind: instance method of App

ParamTypeDescription
objectAppObjectThe AppObject to check.

app.add(object) ⇒ AppObject

Add an AppObject to the App.

Kind: instance method of App

ParamTypeDescription
objectAppObjectThe AppObject to add.

app.remove(object) ⇒ AppObject

Remove an AppObject from the App.

Kind: instance method of App

ParamTypeDescription
objectAppObjectThe AppObject to remove.

app.addFx(object)

Add an AppObject to the FX layer.

Kind: instance method of App

ParamTypeDescription
objectAppObjectThe FX object to add.

app.removeFx(object)

Remove an AppObject from the FX layer.

Kind: instance method of App

ParamTypeDescription
objectAppObjectThe FX object to remove.

app.updateZoom(seconds)

Update the App scale and position based on the targetScale (zoom).

Kind: instance method of App

ParamTypeDescription
secondsNumberThe amount of time passed since the last update.

app.selectObject(object, additive)

Select an AppObject.

Kind: instance method of App

ParamTypeDefaultDescription
objectAppObjectThe object to select.
additivebooleanfalseWhether to add to the current selections, instead of replacing them.

app.select(left, top, right, bottom, additive)

Select all objects within the given coordinates.

Kind: instance method of App

ParamTypeDefaultDescription
leftnumberThe left coordinate. (x1)
topnumberThe top coordinate. (y1)
rightnumberThe right coordinate. (x2)
bottomnumberThe bottom coordinate. (y2)
additivebooleanfalseWhether to add to the current selections, instead of replacing them.

app.selectAll()

Select all objects within the app.

Kind: instance method of App

app.deselectAll()

Deselect all selected objects.

Kind: instance method of App

app.removeSelected()

Remove all selected objects.

Kind: instance method of App

App.defaultOptions ⇒ Object

The default options which are used in an App.

Kind: static property of App

AppObject

AppObjects which are added to the App.

Kind: global class

new AppObject(app, parent, player, position, scale, pivot, rotation, momentum, dampening)

Instantiate a new AppObject.

ParamTypeDescription
appAppThe App the AppObject belongs to.
parentApp | AppObjectThe parent of the AppObject.
playerobjectThe player who owns the AppObject.
positionobjectThe position {x, y} of the AppObject.
scaleobjectThe scale {x, y} of the AppObject.
pivotobjectThe pivot point {x, y} for rotation of the AppObject.
rotationobjectThe rotation of the AppObject.
momentumobjectThe movement speed of the AppObject.
dampeningobjectThe amount that momentum and rotation decreases over time.

appObject.select()

Select this AppObject.

Kind: instance method of AppObject

appObject.deselect()

Deselect this AppObject

Kind: instance method of AppObject

appObject.selectionHitTest()

Check if provided coordinates are cause for the selection of this AppObject

Kind: instance method of AppObject

appObject.beforeUpdate(seconds)

The update operation to occur before all normal update operations within the App.

Kind: instance method of AppObject

ParamTypeDescription
secondsnumberThe number of seconds since the last update.

appObject.update(seconds)

The update operation for the main loop of the App.

Kind: instance method of AppObject

ParamTypeDescription
secondsnumberThe number of seconds since the last update.

appObject.afterUpdate(seconds)

The update operation to occur after all normal update operations within the App.

Kind: instance method of AppObject

ParamTypeDescription
secondsnumberThe number of seconds since the last update.

appObject.updateMovement(seconds)

Update movement based on momentum.

Kind: instance method of AppObject

ParamTypeDescription
secondsnumberThe number of seconds since the last update.

appObject.updateDampening(seconds)

Update movement dampening, causing the AppObject to slow down.

Kind: instance method of AppObject

ParamTypeDescription
secondsnumberThe number of seconds since the last update.

appObject.draw()

Update the visual appearance of the AppObject.

Kind: instance method of AppObject

6.1.2

7 years ago

6.1.1

8 years ago

5.2.0

8 years ago

5.1.0

8 years ago

5.0.0

8 years ago

4.4.1

8 years ago

4.4.0

8 years ago

4.3.0

8 years ago

4.2.1

8 years ago

4.2.0

8 years ago

4.1.1

8 years ago

4.1.0

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.4.0

8 years ago

3.3.0

8 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.1.0

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago