Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Fooshi

I have used the button plugin, the i have created an extended entity in my main init function() like this :

final = ig.game.spawnEntity(button,0,150, {
				text		: ["Tu a gagné"],
				textLength	: 7,
				textPos		: {x:145, y:50},
				anim		: false,
				size		: {x:320, y:168},    
	  			animSheet	: new ig.AnimationSheet('media/final.png', 320, 168)				
			});	
			final.state			= 'hidden';			

but it display me juste one character when the draw function of the entity button is called :

draw: function() {
		
		if (this.state !== 'hidden')
		{	  
			this.parent();
			
			for (var i=0; i<this.text.length; i++)
			{
				ig.game.font.draw( 
				this.text[i], 
				this.pos.x + this.textPos.x - ig.game.screen.x + (i*10), 
				this.pos.y + ((ig.game.font.height + 2) * i) + this.textPos.y - ig.game.screen.y, 
				this.textAlign
			  );
        	}
		}	
    },

this.text.length send me juste 1 character.
What can be the problem ?
thank you

1 decade ago by dominic

Well, you defined your text to be an array with 1 element (a string), so of course its length is 1:
text: ["Tu a gagné"],

And I don&039;t get why you draw your text character by character, when the Font's #draw() method accepts a whole string. See the documentation:
font.draw( 'Some text', x, y, ig.Font.ALIGN.RIGHT );

1 decade ago by stahlmanDesign

@Fooshi

I don't think the impact font engine supports accents such as é, but let me know if you are able to modify it to allow accents.

On a side note, did you notice there's grammar mistake with the conjugation of the verb avoir? It should be:

« Tu as gagné »

1 decade ago by alexandre

unless Tu was intended to be a proper noun, e.g., Mr. Tu Toi. :)

1 decade ago by Fooshi

@Dominic : I have changed my Text to
#text: "Tu a gagne", #
if i use
font.draw( this.text, x, y, ig.Font.ALIGN.RIGHT );"
it display just one character too ...
if i draw one character by character it's because it's in this plugin button https://gist.github.com/1395616

1 decade ago by stahlmanDesign

Remove the [ ] because that makes it an array, and your text.length = 1.

You need to change this line :
text		: ["Tu a gagné"],

to
text		: "Tu as gagné",
Page 1 of 1
« first « previous next › last »