GML How to link sprites like strings?

Here is the code:
GML:
draw_sprite(sStar + sStar + sStar,0,800,432);
I know you can add strings by doing "string" + "string", but is it possible to link sprites as well? if so, how do i do that?
 

Mert

Member
If you really want to add something together :), you can easily do this as
GML:
var distanceBetweenThem = 32;
draw_sprite(sStar,0,800,432);
draw_sprite(sStar,0,800 + distanceBetweenThem,432);
draw_sprite(sStar,0,800 + distanceBetweenThem + distanceBetweenThem,432);
Draw it three times at different coordinates. There you'll have 3 stars
 

SoapSud39

Member
you can also do it with a for loop so you don't have to write the line three times, e.g.
GML:
var distanceBetweenThem = 32;
var numStars = 3;
for (var i = 0; i < numStars; i++) {
    draw_sprite(sStar, 0, 800 + (i * distanceBetweenThem), 432);
}
(this way you can easily change the number of sprites to draw and the distance you want to put between them without having to edit every line)
 

PlayerOne

Member
Another option is to have the stars number of stars be in a single sprite then draw the sprite while using image index and draw the number of starts on screen.

Code:
global.sprite_num = 3
draw_sprite(sStar, global.sprite_num, x,y)
Again have the max number of stars in a single sprite then display however many using image_index.
 
Top