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
randas a function but instead modifies the seed - tileEngine:
frameMarginrenamed tomarginand 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
randfunction by default instead ofMath.randomso 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
spacingproperty for the whitespace between frames - button: allow adding the HTMLButton element to a container
- tileEngine: add
getPositionfunction
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
buttonNameas extra param to gamepad callback - animation: add
startandstopfunctions ,isStoppedproperty
Fixes
- tileEngine: Add
TileEngineClassto exports - gameObject: clamp opacity between 0 and 1
- keyboard: allow
keyPressedto 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
.prototypeand.classproperties of each factory export - sprite: removed
sxandsyproperties from GameObject - keyboard: renamed
bindKeysandunbindKeystoonKeyandoffKey(respectively) - keyboard: renamed keyboard keys
up,down,left,righttoarrowup,arrowdown,arrowleft,arrowright(respectively) - pointer: removed
onPointerDownandonPointerUpand replaced withonPointer(e.g.onPointer('down', callback)) - gameObject: removed
filterFunctionfrom render - helpers: do not return
nullon rotated object forcollides - scene: rename
children,addChild, andremoveChildtoobjects,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
movePointfunction - 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
offPointerfunction - 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