Hi! How can I define enum or string list property in a component? So that developer can pick one of predefined values?
hi, try this
var EnGameState;
EnGameState = cc.Enum({
Pause: 0,
GameStarted: 1,
GamePlaying: 2,
RobotDeath: 3,
GameOver: 4
});
cc.Class({
"extends": cc.Component,
properties: {
GameState: {
"default": EnGameState.GameStarted,
type: EnGameState
}
},
onLoad: function() {
this.GameState = EnGameState.GameStarted
}
});
5 Likes
Thanks it works!