🦔

GameMakerStadio2 サーフェスを利用したエフェクトの作成

に公開

ポイント

サーフェスという画像描画用のメモ帳みたいなところに、一度書きだして、そこで編集後、

実際の画面に描画することで、エフェクトの内部が透明なものを作成できる。

https://x.com/curicuri4343/status/1939235201672192496
create

r は外円の半径 r_in は内円の半径

last_r = 150;
r = 10;
r_in = 2;
time = 0;
surf = noone;


update

last_rの半径に向かってその差分に係数をかけて更新。
はじめは大きく、最後は差分が小さいので移動がゆっくりになる。

r += (last_r - r)*0.13;
r_in += (last_r - r_in)*0.08 + 0.5;

time++;

if(time > 50){
instance_destroy();
}


描画


if(!surface_exists(surf))
{
   surf = surface_create(300, 300);
}
surface_set_target(surf);





draw_clear_alpha(c_black, 0);//サーフェスリセット
draw_set_alpha(1); // アルファ値を 1にする
draw_set_colour(c_white);
draw_circle(150,150,r,false);

gpu_set_blendenable(false); // ブレンドモード無効.
draw_set_alpha(0);
draw_circle(150,150,r_in,false);
draw_set_alpha(1);
gpu_set_blendenable(true);


surface_reset_target();



draw_set_colour(c_black);

gpu_set_blendmode(bm_normal);
draw_surface(surf, x - 150, y - 150);


破棄

surface_free(surf);

Discussion