- Joined
- Jan 5, 2016
- Messages
- 734
- Reaction score
- 605
- First Language
- French
- Primarily Uses
Hi everyone!
I'm trying to draw text on the map.
I did it by using a picture: here is how I do it:
Game_Screen.prototype.draw_text = function(id,text,x,y,align,width,height) {
width = width || 812
height = height || 624
align = align || "left"
var a = SceneManager._scene._spriteset._pictureContainer.children[id-1]
if (!a.bitmap) {
a.bitmap = new Bitmap(width,height)
}
$gameScreen.showPicture(id, '', 0, 0, 0, 100,100, 255, 0);
a.bitmap.clear()
a.bitmap.drawText(text ,x ,y ,width ,height ,align)
}
What i cannot comprehend is: why is the text displayed mid screen instead of at 0,0 ?
Here is how it looks:
The script call is:
$gameScreen.draw_text(2,"Alpha",0,0)
If you have any idea why I would be so grateful! I've been searching for hours.
Returning the y position of the picture returns 0 as it should. And by moving the picture to -312 I get the text where it should be. But I am writing on the image at 0,0 not 0,312 so why is the text displayed there?
The project I wrote the function on literally has only that plugin in it. Strictly default other than that, so no interference from any other plugin.
Gah. I don't understand, my function is logical, my script call is valid... Clearly I must be missing something.
I'm trying to draw text on the map.
I did it by using a picture: here is how I do it:
- Get the picture id
- Create a new bitmap for the picture if there is none. The bitmap will be the size of the screen.
- Display the picture at 0,0
- Modify the picture bitmap by first clearing it, then drawing text at the x,y coordinates
Game_Screen.prototype.draw_text = function(id,text,x,y,align,width,height) {
width = width || 812
height = height || 624
align = align || "left"
var a = SceneManager._scene._spriteset._pictureContainer.children[id-1]
if (!a.bitmap) {
a.bitmap = new Bitmap(width,height)
}
$gameScreen.showPicture(id, '', 0, 0, 0, 100,100, 255, 0);
a.bitmap.clear()
a.bitmap.drawText(text ,x ,y ,width ,height ,align)
}
What i cannot comprehend is: why is the text displayed mid screen instead of at 0,0 ?
Here is how it looks:

The script call is:
$gameScreen.draw_text(2,"Alpha",0,0)
If you have any idea why I would be so grateful! I've been searching for hours.
Returning the y position of the picture returns 0 as it should. And by moving the picture to -312 I get the text where it should be. But I am writing on the image at 0,0 not 0,312 so why is the text displayed there?
The project I wrote the function on literally has only that plugin in it. Strictly default other than that, so no interference from any other plugin.
Gah. I don't understand, my function is logical, my script call is valid... Clearly I must be missing something.