Resizing from middle

F

Furiosposion

Guest
Hello,
i'm trying to have an item spawn animation, like a coin spawns small and gets bigger to normal size.
but basic y+=1 and x+=1 resizes it from one corner, i want it to resize from middle like in the picture
could anyone help me with it? thanks.
upload_2019-11-2_19-14-57.png
 
If you are resizing it using image_xscale and image_yscale, have you tried setting the sprite origin to the center of the image?
 
F

Furiosposion

Guest
yes origin is on center and i do use
xs +=0.2
ys +=0.2;
draw_sprite_ext(s_drop,item_id, xx, yy,xs,ys,0,c_white,1);
 
F

Furiosposion

Guest
i've tried with image_xscale and center origin, it works, but also using with draw_sprite_ext works, i literally have no idea why this code doesn't:
Code:
Step:
//Spawning item
for (var a = 0; a < ds_list_size(item_xsize); a++){
var xs = ds_list_find_value(item_xsize, a);
var ys = ds_list_find_value(item_ysize, a);
if (xs < 1){
xs += 0.02;
ys += 0.02;
ds_list_replace(item_xsize,a,xs);
ds_list_replace(item_ysize,a,ys);}}

Draw:
for (a = 0; a < ds_list_size(item_xsize); a++){
 var xs = ds_list_find_value(item_xsize, a);
 var ys = ds_list_find_value(item_ysize, a);     
 draw_sprite_ext(s_coin, 0, xx, yy,xs,ys,0,c_white,1);
 
Last edited by a moderator:
C

Catastrophe

Guest
ds_list_size(400) is probably not doing what you think it's doing, (you probably want ds_list_size(item_x_whateveritis)), and you have a missing parenthesis after a++, so I guess this wasn't pasted 100%.

Also, if this is bugging out, it should be pretty easy to catch by just using show_message on variables and inside loops. If you don't want a spam, just show_message on (if a = 0)
 
Last edited by a moderator:
F

Furiosposion

Guest
ds_list_size(400) is probably not doing what you think it's doing, (you probably want ds_list_size(item_x_whateveritis)), and you have a missing parenthesis after a++, so I guess this wasn't pasted 100%.

Also, if this is bugging out, it should be pretty easy to catch by just using show_message on variables and inside loops. If you don't want a spam, just show_message on (if a = 0)
There is no any problem at code, it works as expected it only +'s each items' size, the issue is on it gets resized from corner, not middle even the origin is on center.

and yes that ds_list_size is normally ds_list_size(item_xsize); (i edited to post here)
 
C

Catastrophe

Guest
Well, what I'm saying is, ds_lists aren't going to somehow distort image resizing. If a regular draw_sprite_ext is doing things correctly, that means you are probably fetching incorrect values from your ds_lists or putting incorrect values in there, and a show_message on results would reveal this if it were the case.
 
Last edited by a moderator:
Top