Closed Brian151 closed 7 years ago
Here you go:
var Game = stampit.init(function (){
this.state = "standby";
var self = this;
this.timingTick = 33; //approx 30 FPS
this.timingDraw = 0;
this.deltaTime = 0;
this.deltaTime2 = 0;
this.timeNow = Date.now();
this.timeLast = this.timeNow;
this.ticks = 0;
this.draws = 0;
})
Now you can create instances of your Game:
var game = Game();
console.log(game.timeLast); // 1502324424317
Of course, if you need some default properties you do it your way:
var Game = stampit
.props({
state: "standby",
timingTick: 33, //approx 30 FPS
timingDraw: 0,
deltaTime: 0,
deltaTime2: 0,
timeNow: null, // will initialize on creation
timeLast: null, // will initialize on creation
ticks: 0,
draws: 0
})
.init(function (){
this.timeNow = Date.now();
this.timeLast = this.timeNow;
})
Fell free to ask any questions.
most of them won't need to be initalized, but yep... thx!
The API docs are still very confusing, and I have a tad bit of a problem:
how do i handle the timeLast with stamps? I currently have...
I'm assuming I need to use the initializers? but, the API docu is not terribly clear how I actually must do this...