9 years ago by iast
Hi, i just joined and still learning. Actually i stuck with this,
when i creating the background with system.context.drawimage, it is work and i can resize the image. while i want to add an entity of button, the button does not appear. Here is the code of game extend:
And this is the entity of button:
What make me confuse is whenever i uncomment this.parent on game extend, the button will appear, but the background is disappear. Anyone please?
when i creating the background with system.context.drawimage, it is work and i can resize the image. while i want to add an entity of button, the button does not appear. Here is the code of game extend:
GameOxygen = ig.Game.extend({ font: new ig.Font( 'media/04b03.font.png' ),// Load a font bgtitle: new FullsizeBackground('media/titlebg.png'), title: new ig.Image('media/title.png'), player: null, init: function() { this.player = this.spawnEntity(EntityButton,10,10); }, draw: function() { var image = this.bgtitle.data; ig.system.context.drawImage( image, 0, 0, 640, 480); //this.parent(); } });
And this is the entity of button:
EntityButton = ig.Entity.extend({ size: {x:50,y:50}, type: ig.Entity.TYPE.B, animSheet : new ig.AnimationSheet('media/button.png',92,86), isClicked: false, init: function(x,y,settings){ this.addAnim('normal', 1,[0]); this.addAnim('click', 1,[1]); this.parent(x,y,settings); }, update: function(){ if (this.isClicked) { this.currentAnim = this.anims.click; }else{ this.currentAnim = this.anims.normal; } this.parent(); }, handleMovementTrace: function( res ) { this.parent(res); }, clicked: function(){ } }); });
What make me confuse is whenever i uncomment this.parent on game extend, the button will appear, but the background is disappear. Anyone please?