Mike Posted April 23, 2013 Share Posted April 23, 2013 So I've got little to no time, but i really like TypeScript and Phaser and i've just make a small edit to one of the demos: var car: Phaser.Sprite; var miniCam: Phaser.Camera; var turbo: bool = true; var turboDuration: number = 5 * 1000; var turboCooldown: number = 20 * 1000;and then in the update function: if (myGame.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) { if (turbo) { var motion: Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 600); car.velocity.copyFrom(motion); setTimeout(function () { turbo = false; setTimeout(function () { turbo = true; }, turboCooldown); }, turboDuration); } } So you can easily copy paste or just imagine the result. My question is do you think, there is a better approach also i tough for making turbo, turboDuration, turboCooldown properties of car but TypeScript doesn't like adding properties to objects later on like: car.turbo = false; Since compiler checks that car is of type Phaser.Sprite and that there isn't property "turbo" So share your ideas Link to comment Share on other sites More sharing options...
rich Posted April 23, 2013 Share Posted April 23, 2013 You could achieve this with acceleration and drag But I'll be porting over my ControlHandler from the flixel power tools which will make this a breeze, just need to sort out some bigger issues first. Link to comment Share on other sites More sharing options...
Recommended Posts