GMS 2 [Solved] Programmatically number sprites

Cupid Stunt

Member
I'm working on a math learning game that uses tiles for the potential answers as well as the questions. The range of the answers is 0-19, so it was easy to make a single sprite that had all of the numbers on different frames. Then to use the image_index to set the number and store which number is on the tile for checking later.

and it works well because I can restrict the range as needed and make a nice looking play board.


The issue that I have now is that there are a lot more than 20 possibilities for the question tiles and I hand drew all of these tiles that I already have.
So my question is, besides making a tile and text fall at the same rate on overlapping layers, is there a way to stamp a number or string onto a blank tile from within the code?
So if I need say 143 on a tile I can just use a built-in function to put it on there and then just have the single connected tile instance to manage?
This is a gml project in studio 2.
 

TheouAegis

Member
draw_text() can be your stamp.
Store the value you want "stamped" in an array or other data structure, then draw that value over the corresponding tile.
 

Cupid Stunt

Member
draw_text() can be your stamp.
Store the value you want "stamped" in an array or other data structure, then draw that value over the corresponding tile.
That is what I was thinking of for the fall back. The reason why I didn't go with that right away is because of movement. Unless I'm wrong I will have to move the tile and then draw_text() again with the updated x and y, or have I made a mistake in my understanding?
 

Cupid Stunt

Member
draw_text() can be your stamp.
Store the value you want "stamped" in an array or other data structure, then draw that value over the corresponding tile.
I think this video
combined with your answer will do what I want.

My mistake was thinking that draw_text() had to be used by the object that spawns the answer tile, when I can just use it from inside of the tile's draw event.

Thank you for your answer.
 

Cupid Stunt

Member
draw_text() can be your stamp.
Store the value you want "stamped" in an array or other data structure, then draw that value over the corresponding tile.
I just had to put
Code:
draw_self();
draw_set_color(c_black)
draw_text(x, y, "123");
into the draw event and do the normal changes to x, y
Thanks for your help
 
Top