Releases: straker/kontra
v10.0.2
v10.0.1
v10.0.0
Migrates the seedRand
and randInt
functions to a new PRNG module. In so doing this breaks how seedRand
and randInt
works. It also updated the PRNG algorithm to use SplitMix32 instead of LCG and the string hashing algorithm from xfnv1a to MurmurHash3.
This release also updates TileEngine to support spacing
property and renames the frameMargin
property to margin
and updates it to mean margin around the tilesheet instead of margin between each frame.
Breaking Changes
- seedRand: no longer returns
rand
as a function but instead modifies the seed - tileEngine:
frameMargin
renamed tomargin
and means margin around the tilesheet
Features
- seedRand: also now accepts a string or defaults to the current time if no value is passed
- randInt: accepts a function as 3rd parameter which can be used to pass a function that can bias the random number
- randInt: uses
rand
function by default instead ofMath.random
so is affected by seeding the PRNG - rand: function that returns a seeded random number between 0 and 1
- getSeed: function that returns the current random seed value
- button,scene: expose the HTML node property
- gameObject: add angular velocity and acceleration
- tileEngine: support flipped and rotated tiles in Tiled
- tileEngine: support the
spacing
property for the whitespace between frames - button: allow adding the HTMLButton element to a container
- tileEngine: add
getPosition
function
Fixes
- gameLoop: prevent zombie frame when start is called twice
- gameLoop: emit tick event every update
- prevent scrolling page on element focus
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