1 decade ago
by jswart
How could I create custom properties for an entity? I want to create a custom entity
EntityScoreKeeper
The ScoreKeeper entity will have the properties: player_score, and cpu_score. These properties will be updated in the main.js as other events take place.
How can I define these custom properties. In addition is there a better way to do this?
1 decade ago
by jswart
I figured out the answer to my own question. For anyone else who comes along here is the answer:
Add your custom properties just like you would the inherited properties, then add the entity to you game in the editor. Should be good to go.
This video helped me, specifically the 'kill' entity about 1/2 through the video
http://vimeo.com/17163174
ig.module(
'game.entities.score-keeper'
)
.requires(
'impact.entity'
)
.defines(function(){
EntityScoreKeeper = ig.Entity.extend({
_wmDrawBox: true, // show up only in editor
_wmBoxColor: 'rgb(0 255 0)', // color of entity box in editor
player_score: 0, // custom property
cpu_score: 0, // custom property
init: function( x, y, settings ) {
}
});
});
I can't imagine you would need an entity to keep track of scores. You could just store player_score and cpu_score in main and use the text drawing to display it on the screen wherever you wanted.
1 decade ago
by mimik
do what just did but add it to the main.js. ig.game.
Then you can call it from ig.game.cpu_score
Page 1 of 1
« first
« previous
next ›
last »