-
accelerate()method no longer has a delay value as a parameter. This means the the method_advanceNoDelay()has disappeared and the code it held folded intoaccelerate(). -
I did not remove the
wait()method. I am using it in examples and dont want to loose it. But if you want you can take it out. -
I found a better way to calculate velocity at each point in an acceleration and have implemented that.
-
I have implemented a
SimpleAcceleratorclass that is the parallel ofBezierAcceleratorand is used when one of dF of dT is set equal tonull. -
I have implemented unit testing for
- Function values. Checking that the bezier accelerator and simple accelerator keep getting the same answers.
- Completion of acceleration and wait operations. I check the promises are resolved correctly even for
kill(). Have not yet tested overwrite ofacceleration()
-
The code is now
lint free- I agree that it certainly makes for more uniform code -
I built a little sample game in
example/gamethat uses theAcceleratorclass to play a slot machine style experience. It might be helpful. -
The example in this
readme.mddoes not work because the ticker function called as a result ofwindow.requestAnimationFrame(ticker); -
is passed an absolute time of day in milliseconds not a PIXI.ticker delta.
- Build a few more tests. Particularly related to sequences of
wait,accelerate,kill - Work on using the BezierAccelerator's callback function to signal end of an acceleration. There is a problem doing this
when a
kill()is called and I have not figured out the problem.
- Wait function
- Kill function
- Ammend/Overwrite
- Handle last tick
- Handle accelerate without distance constraint
import Accelerator from 'Accelerator'
const initVelocity = 0
const carAccelerator = new Accelerator(initialVelocity)
// animate on frame
function ticker(delta)
{
carAccelerator.advanceTimeBy(deltaTime)
car.position.x = carAccelerator.getPosition()
window.requestAnimationFrame(ticker);
}
window.requestAnimationFrame(ticker);
// Promise based
carAccelerator.accelerate(newV1, overTime1, overDistance1)
.then(carAccelerator.accelerate(newV2, overTime2, overDistance2))
.then(carAccelerator.accelerate(newV3, overTime3, overDistance3))
.then(console.log('done'))
const initialVelocity = 0;
const options = {
timeInterval: 1/60, //default
allowOverwrite: true //default
}
const myAccelerator = new Accelerator(initialVelocity, options)Advance the moving objects time by a time interval
myAccelerator.advance(delta)Gets the current position of the moving object
myAccelerator.getPosition()Gets the current velocity of the moving object
myAccelerator.getVelocity(v)Sets the velocity. This cannot bet set during an acceleration
myAccelerator.setVelocity(v)Instructs the object to start a velocity change
myAccelerator.accelerate(vF, tF, dF, delay = false)Lets a timeinterval pass during which the accelerator moves along at a constant velocity.
myAccelerator.wait(delay)Stops any current acceleration & resolves the acceleration promise
myAccelerator.kill()Show all commands
npm run helpBuild, watch & lint
npm startBuild transpiled, and transpiled & minified
npm run buildRun tests
npm testRun the tests & watch
npm run lint:watchRun the linter
npm run lintRun the linter & watch
npm run lint:watch