Skip to content

v7.0.0

Compare
Choose a tag to compare
@straker straker released this 11 Aug 17:24
· 187 commits to main since this release

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