fix buttons in level selector

This commit is contained in:
Juraj Michalek
2015-12-28 09:45:13 +01:00
parent 945b332c86
commit b5d46257db

View File

@@ -5,13 +5,22 @@ levelSelectorState.preload = function() {
}
levelSelectorState.create = function() {
var counterX = 0;
var counterY = 0;
for (var i=1; i<levels.length+1; i++) {
var text = new Kiwi.GameObjects.Textfield( this, "Level " + i.toString(), 16+(i-1)*140, 60, "#000", 32, 'normal', 'Impact' );
var sprite = new Kiwi.GameObjects.Sprite(this, this.textures.button, (i-1)*140, 50);
var text = new Kiwi.GameObjects.Textfield( this, "Level " + i.toString(), 16+counterX*140, 60+counterY*80, "#000", 32, 'normal', 'Impact' );
var sprite = new Kiwi.GameObjects.Sprite(this, this.textures.button, counterX*140, 50+counterY*80);
sprite.levelIndex = i;
sprite.input.onUp.add( this.buttonReleased, this );
this.addChild( sprite );
this.addChild( text );
counterX++;
if (counterX > 4) {
counterX = 0;
counterY++;
}
}
}