Skip to content

Releases: straker/kontra

v9.0.0

27 Jan 03:56
Compare
Choose a tag to compare

The angleToTarget helper class was returning the wrong angle due to an incorrect use of sin and cos, resulting in adding a quarter rotation. This has been fixed which causes a breaking change from the value that was returned before (no longer adds a quarter rotation).

Breaking Changes

  • helpers: return correct angle from angleToTarget

Features

  • vector: add direction function
  • vector: add set function and allow initialize with object
  • text: add text stroke
  • gamepad: pass buttonName as extra param to gamepad callback
  • animation: add start and stop functions ,isStopped property

Fixes

  • tileEngine: Add TileEngineClass to exports
  • gameObject: clamp opacity between 0 and 1
  • keyboard: allow keyPressed to accept array of keys
  • vector: handle normalizing zero vector
  • text: correctly handle string with both newlines and a fixed width
  • allow objects to be created before init
  • pointer: correctly track objects when scene/tileEngine camera is moved
  • tileEngine: prevent negative sx/sy when map size is smaller than canvas size

v8.0.0

13 Feb 04:58
Compare
Choose a tag to compare

Many properties and functions have been renamed to better align the various APIs and support the new Input wrapper API. Also to support building the library with esbuild all .prototype and .class properties were removed and replaced with the new *Class export (e.g. import { SpriteClass } from 'kontra')

Breaking Changes

  • removed .prototype and .class properties of each factory export
  • sprite: removed sx and sy properties from GameObject
  • keyboard: renamed bindKeys andunbindKeys to onKey and offKey (respectively)
  • keyboard: renamed keyboard keys up, down, left, right to arrowup, arrowdown, arrowleft, arrowright (respectively)
  • pointer: removed onPointerDown and onPointerUp and replaced with onPointer (e.g. onPointer('down', callback))
  • gameObject: removed filterFunction from render
  • helpers: do not return null on rotated object for collides
  • scene: rename children, addChild, and removeChild to objects, add, and remove (respectively)

Features

  • gesture: add swipe and pinch gesture support
  • gamepad: add gamepad api
  • input: add input wraper api
  • button: button can be disabled when created @alfi-s
  • allow esbuild to tree shake library @anderoonies
  • tileEngine: add preprocessor support for TileEngine
  • helpers: add movePoint function
  • grid: allow setting alignment for individual rows or cols, allow setting children
  • core: allow contextless environment
  • tileEngine, gameObject: remove camera from sprite, have tileEngine render all objects
  • pointer: add offPointer function
  • scene,helpers: allow scene to sort chlidren. add depthSort helper

Bug Fixes

  • Text cast value to string when setting Text.text @anderoonies
  • grid work with colSpan > 2
  • grid take into account child world width and height
  • srOnly add clip to sr only style
  • sprite translate by camera position before rotation
  • gameObject correctly calculate world position when nested children are rotated
  • ts fix load and loadData types to accept array

v7.3.1

03 Sep 21:57
Compare
Choose a tag to compare

feat(assets): support webp images

v7.2.0

19 Aug 03:06
Compare
Choose a tag to compare
  • feat(gameLoop): do not update loop when tab is blurred
  • feat(keyboard): preventDefault for all bound keys
  • feat(pointer): initPointer can change radius
  • fix(types): make "dt" always exist in update @sheepsteak
  • fix(utils): update srOnlyStyles
  • fix(grid): reverse colGap when dir=rtl

v7.1.3

20 Mar 02:48
Compare
Choose a tag to compare
  • fix(keyboard): allow keyup support for bindKeys
  • fix(text): cast text to string
  • fix(helpers/getWorldRect): work with tileEngine

v7.1.2

23 Aug 16:03
Compare
Choose a tag to compare
  • fix(helpers.getWorldRect): adjust for negative scale values

v7.1.1

20 Aug 03:55
Compare
Choose a tag to compare
  • fix: properly export helpers.rotatePoint()

v7.1.0

17 Aug 19:04
Compare
Choose a tag to compare
  • feat(helpers): add getWorldRect
  • fix(gameObject): call custom update function when group is turned off
  • fix(pointer): account for camera
  • fix(pointer): account for border, padding and transform

v7.0.0

11 Aug 17:24
Compare
Choose a tag to compare

Breaking Changes

Sprite

  • When drawing a sprite, the sprite has now been translated to the proper location to start drawing the sprite. You should use 0, 0 to start drawing instead of this.x, this.y.
- this.context.fillRect(this.x, this.y, this.width, this.height);
+ this.context.fillRect(0, 0, this.width, this.height);
  • Removed support for flipping an image using a negative width/height. Use the new setScale to set the scale to a negative value to flip.
  • viewX and viewY removed
  • collidesWith removed. Use the new kontra.collides helper function

keyboard

  • Removed support for KeyboardEvent.keycode as KeyboardEvent.code now works in all major browsers

pointer

  • Removed kontra.pointer. Use the new kontra.getPoiner.

Vector

  • add no longer accepts the dt parameters. Use the new Vector.scale function to scale a vector.

Features

Assets

  • Support for .wav files

Button

Button is a new component which allows you to create accessible Buttons for your game.

GameLoop

  • pass canvas to change which canvas is cleared.

GameObject

GameObject is a new parent class for Sprite and handles most rendering functionality. You should continue to use Sprite as you do today. New features include:

  • opacity support
  • scaleX, scaleY, and setScale for scale support
  • world for getting the world position, size, opacity, scale, and rotation
  • children, parent, addChild, and removeChild for grouping support

Grid

Grid is a new component which helps you easily create UI menus by auto-placing objects into a grid.

Helpers

A group of helpful functions.

  • kontra.degToRad
  • kontra.radToDeg
  • kontra.angleToTarget
  • kontra.rotatePoint
  • kontra.randInt
  • kontra.seedRand
  • kontra.lerp
  • kontra.inverseLerp
  • kontra.clamp
  • kontra.setStoreItem
  • kontra.getStoreItem
  • kontra.collides

pointer

  • kontra.initPointer returns the pointer object
  • can now work with multiple canvases by passing the canvas to initPointer and getPointer

Scene

Scene is a new component to organize the differnet parts of your game

Text

Text is a new component to write text to the canvas

Vector

  • Vector​.angle
  • Vector​.clamp
  • Vector​.distance
  • Vector​.dot
  • Vector​.length​
  • Vector​.normalize
  • Vector​.scale
  • Vector​.subtract

v6.9.1

10 Dec 20:35
Compare
Choose a tag to compare

fix(tileEngine): don't error for object layers @andre-lima