Text Rotate With Sprite (Get A Free Game)

N

NodziGames

Guest
So I'm making a CCG, and instead of putting the name on a card, I use draw_text_transformed so that I don't have to create a separate sprite for each one. It also works with scaling, so that I can resize the card without problems. This is my current code: (All in the draw event)



//Draws The Card, which consists of 3 sprites, spr_base is the bottom, spr_face is the character on the card, and spr_overlay is the rarity indicator. Scale is 1 at this stage

draw_sprite_ext(spr_base, 0, x, y, scale, scale, angle, c_white, 1);
draw_sprite_ext(spr_face, 0, x, y, scale, scale, angle, c_white, 1);
draw_sprite_ext(spr_overlay, 0, x, y, scale, scale, angle, c_white, 1);

//Draw Name
draw_set_font(fnt_main);
draw_set_color(c_black);
draw_set_halign(fa_right)
draw_text_transformed(x + (300 * scale) - (27 * scale), y - (400 * scale) + (28 * scale), name, scale, scale, angle);
draw_set_color(c_white);
draw_text_transformed(x + (300 * scale) - (27 * scale) + 2, y - (400 * scale) + (26 * scale), name, scale, scale, angle);


11.png 22.png
The sprite is 600 x 800 in size, so the 300*scale moves the point to the right since the origin of the card sprite is in the center. the 27 * scale is just the offset so that it's not printed completely on the side.

The attached images gives you an idea with what I'm struggling with.

I'd greatly appreciate any maths expert to help me out! As a matter of fact, whoever can solve this for me gets 5 free Steam Keys for "Gal-X-E"

Good day!
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Something like this,
Code:
var ox = 300 - 27;
var oy = 28 - 400;
var _x = x + (lengthdir_x(ox, angle) + lengthdir_x(oy, angle - 90)) * scale;
var _y = y + (lengthdir_y(ox, angle) + lengthdir_y(oy, angle - 90)) * scale;
draw_text_transformed(_x, _y, name, scale, scale, angle);
You'll need to adjust coordinates based on rotated relative position at both axes.
 
N

NodziGames

Guest
Something like this,
Code:
var ox = 300 - 27;
var oy = 28 - 400;
var _x = x + (lengthdir_x(ox, angle) + lengthdir_x(oy, angle - 90)) * scale;
var _y = y + (lengthdir_y(ox, angle) + lengthdir_y(oy, angle - 90)) * scale;
draw_text_transformed(_x, _y, name, scale, scale, angle);
You'll need to adjust coordinates based on rotated relative position at both axes.
Thank you so much! It works like a dream. I just realized how close I was to the answer, but you swooped in to save the day! As promised, you won 5 Steam keys for Gal-X-E. How can I contact you?
 
Top