hmm I seem to be stuck with the mentality that all images must belong to some entity
what I need is to add an image to a text
i have this while the game is running:
this.font.draw(message,ig.system.width/2,ig.system.height/2,ig.Font.ALIGN.CENTER);
I just want to draw a small image of 50x50 pixels under the message, but I don't want to create a whole new entity (because it might interact with the other objects in-game). I don't think I'm allowed to do this.draw(image)....
what's the best way to do this?
my bad, this seemed to do the trick
ig.module(
'game.entities.something'
)
.requires(
'impact.entity'
)
.defines(function(){
EntitySomething=ig.Entity.extend({
size:{x:32,y:32},
animSheet:new ig.AnimationSheet('media/sprites/something.png',32,32),
init:function(x,y,settings){
this.parent(x,y,settings);
this.addAnim('saved',0.05,[0,1]);
this.addAnim('idle',0.2,[0,1,2,3]);
this.currentAnim = this.anims.idle;
this.currentAnim.flip.x = true;
},
update:function(){}})
;}
);
mmm doesn't seem to work well
what I need is the image to stay fixed at its original location (even if the player and camera moves )
kind of thinking along the lines of a health bar, which always stays at the bottom of the screen regardless of where the player/camera is.
1 decade ago
by dominic
ig.Image (or ig.Animation) doesn't need an entity. This should work:
MyGame = ig.Game.extend({
testImage: new ig.Image( 'media/test.png' ),
draw: function() {
this.parent();
this.testImage.draw( 0, 0 );
}
});
See the synopsis for
ig.Image and
ig.Animation.
MyGame = ig.Game.extend({
testImage: new ig.Image( 'media/test.png' ),
draw: function() {
this.parent();
this.testImage.draw( this.screen.x, this.screen.y );
}
});
If you want it to stick to the screen
1 decade ago
by Sledge
Maybe this is a dumb question, but can you also draw images in this way while using the impact.js implementation of box2D?
1 decade ago
by Joncom
Quote from Sledge
Maybe this is a dumb question, but can you also draw images in this way while using the impact.js implementation of box2D?
Absolutely. Drawing of images is no different when using Box2D or otherwise.
1 decade ago
by Joncom
Quote from arronlee
Quote redacted due to being spam.
Drawing an image with ImpactJS is as simple as:
var img = new ig.Image('image.png');
img.draw(0, 0);
See the documentation for more information.
Page 1 of 1
« first
« previous
next ›
last »