Reputation: 440
I am trying to convert the Luxurious animals tutorial on combining createjs and box 2d, to Typescript. So far the mess I'm making seems to be working. But now I'm getting a Uncaught TypeError: Cannot call method 'push' of undefined
on this line:
this.actors.push(this);
But actors
is defined on the .ts as private actors = [];
. I've tried may ways but none work. Anyone knows whats going on?
app.ts => http://paste.laravel.com/8HM default.html => http://paste.laravel.com/8HN
Using VS 2012.
Upvotes: 2
Views: 279
Reputation: 440
Ok, so the problem was that it wasn't calling actorObject
as a method, but creating it as an object: new Box2d.actorObject
.
I just made is as a class of it's own and it's all pretty now.
Upvotes: 1
Reputation: 11284
Try private actors:TYPE[] = [];
where TYPE
is the type of your array, e.g. for an array of strings private actors:string[] = [];
This seems to be working for me.
If not, then maybe post some more code - I can't get your .ts files to come up in source view from the links you've posted, and I can't tell which of the (several) scripts in the page your issue is with.
Upvotes: 1