Releases: straker/kontra
v9.0.0
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
andstop
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
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
andsy
properties from GameObject - keyboard: renamed
bindKeys
andunbindKeys
toonKey
andoffKey
(respectively) - keyboard: renamed keyboard keys
up
,down
,left
,right
toarrowup
,arrowdown
,arrowleft
,arrowright
(respectively) - pointer: removed
onPointerDown
andonPointerUp
and replaced withonPointer
(e.g.onPointer('down', callback)
) - gameObject: removed
filterFunction
from render - helpers: do not return
null
on rotated object forcollides
- scene: rename
children
,addChild
, andremoveChild
toobjects
,add
, andremove
(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
v7.2.0
- 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
v7.1.2
v7.1.1
v7.1.0
v7.0.0
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 ofthis.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
andviewY
removedcollidesWith
removed. Use the newkontra.collides
helper function
keyboard
- Removed support for KeyboardEvent.keycode as KeyboardEvent.code now works in all major browsers
pointer
- Removed
kontra.pointer
. Use the newkontra.getPoiner
.
Vector
add
no longer accepts thedt
parameters. Use the newVector.scale
function to scale a vector.
Features
- Support to remove code inside Classes through rollup-plugin-kontra.
- typescript support
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
supportscaleX
,scaleY
, andsetScale
for scale supportworld
for getting the world position, size, opacity, scale, and rotationchildren
,parent
,addChild
, andremoveChild
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
andgetPointer
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
fix(tileEngine): don't error for object layers @andre-lima