GameMaker 日本語掲示板

パーティクルを使用すると不規則にGUIがちらつく

14 コメント
views
16 フォロー

パーティクルを発生させるとほかのGUI表示が不規則に非表示になります。(高頻度)
ドットのしぶきを発生させるような小規模なものなのですが、パーティクルの作り方がミスってて重すぎるのか…分からないです
パーティクル使ってる方同じような現象が発生することはありますか?。

yakata
作成: 2021/09/18 (土) 20:43:55
通報 ...
1
生高橋 2021/09/18 (土) 21:33:27

GMSのバグの可能性もありそうですが
パーティクルのコードとGUI表示のコードがまず怪しそうですね。
その箇所って見せられそうですか?

2

パーティクルObjのcreate_event

pp=global.main_player
col_ten=make_color_rgb(255,170,60);

FirstParticleSystem = part_system_create();
part_system_depth(FirstParticleSystem,-500);
first_particle = part_type_create();

part_type_shape(first_particle,pt_shape_pixel);
part_type_scale(first_particle,1,1);
part_type_size(first_particle,1,1,0,0);//wigleとは反復のことらしい
part_type_color2(first_particle,col_ten,col_ten);
part_type_alpha3(first_particle,1,1,0.8);//透明度
part_type_speed(first_particle,3,5,-0.015,0);//粒子速度
part_type_direction(first_particle,35,55,0,0);//方向
part_type_gravity(first_particle,0.04,-90);//重力。強さと、方向
part_type_orientation(first_particle,0,0,0,0,false);//回転
part_type_life(first_particle,20,30);//寿命
part_type_blend(first_particle,false);//ブレンド

//ここからエミッタ
first_emitter = part_emitter_create(FirstParticleSystem);
part_emitter_region(FirstParticleSystem, first_emitter,  x-1, x+1, y-1, y+1, ps_shape_line, ps_distr_linear);

パーティクルObjのuser_event0

pp=global.main_player
pp_tg=global.main_player.target_enemy

//以下プレイヤーの攻撃方向と対象エネミーの位置を反映させる処理
part_system_depth(FirstParticleSystem,-pp.play_y+4);
part_emitter_region(FirstParticleSystem, first_emitter,  pp_tg.play_x-1, pp_tg.play_x+1, pp_tg.play_y-52, pp_tg.play_y-52, ps_shape_line, ps_distr_linear);
if(pp.doujiosi_bottan=1||pp.doujiosi_bottan=11||pp.doujiosi_bottan=12){
	part_type_direction(first_particle,0,20,0,0);
}
			
if(pp.doujiosi_bottan=2||pp.doujiosi_bottan=22||pp.doujiosi_bottan=21){
part_type_direction(first_particle,160,180,0,0);
}
			
if(pp.doujiosi_bottan=3||pp.doujiosi_bottan=33||pp.doujiosi_bottan=34){
	part_system_depth(FirstParticleSystem,-pp.play_y-1);
	part_type_direction(first_particle,250,290,0,0);
	//した
}
			
if(pp.doujiosi_bottan=4||pp.doujiosi_bottan=44||pp.doujiosi_bottan=43){
	part_emitter_region(FirstParticleSystem, first_emitter,  pp_tg.play_x-1, pp_tg.play_x+1, pp_tg.play_y-32, pp_tg.play_y-32, ps_shape_line, ps_distr_linear);
part_type_direction(first_particle,70,110,0,0);	
	//上
}
				
if(pp.doujiosi_bottan=13||pp.doujiosi_bottan=31){
part_system_depth(FirstParticleSystem,-pp.play_y-1);
	part_type_direction(first_particle,315-10,315+10,0,0);
	//右下
}
if(pp.doujiosi_bottan=14||pp.doujiosi_bottan=41){
		part_emitter_region(FirstParticleSystem, first_emitter,  pp_tg.play_x-1, pp_tg.play_x+1, pp_tg.play_y-32, pp_tg.play_y-32, ps_shape_line, ps_distr_linear);
	part_type_direction(first_particle,35,55,0,0);
	//右上
}
if(pp.doujiosi_bottan=23||pp.doujiosi_bottan=32){
	part_system_depth(FirstParticleSystem,-pp.play_y-1);
	part_type_direction(first_particle,225-10,225+10,0,0);
	//左下
}
if(pp.doujiosi_bottan=24||pp.doujiosi_bottan=42){
	part_emitter_region(FirstParticleSystem, first_emitter,  pp_tg.play_x-1, pp_tg.play_x+1, pp_tg.play_y-32, pp_tg.play_y-32, ps_shape_line, ps_distr_linear);
	part_type_direction(first_particle,135-10,135+10,0,0);
	//左上
}
//方向と位置が決まったので80個生成
part_emitter_burst(FirstParticleSystem, first_emitter,first_particle,80);
3

かなり読みづらいと思われますすみません。
プレイヤーがエネミーにぶつかったときにその方向に向けてドットのしぶきを飛ばすパーティクルになります。
パーティクルObjはルーム開始時に生成しておいてヒット時にuser_event0を呼び出す形です。

4

消えてしまう方のGUI表示は画面上に常に表示するHPバーなどのHUDで、複数のHUDが不規則に消えるので特定の表示コードがあるわけではないのですが大抵

draw_sprite_ext()

で描画しています。今気が付きましたが消える際は一つのobjにコードのある表示が丸々消えていますね、やっぱり処理が重いんですかね…

5

パフォーマンス面を見るために、
show_debug_overlay(true);
として、fpsやテクスチャスワップの情報を表示してみてください。
もう1つ、デバッガで動かして左上に表示されるグラフ?部分を見てください。
できればそれらのキャプチャ画像をここに貼れるでしょうか?
何か分かるかも知れません。

6
生高橋 2021/09/18 (土) 23:34:26

問題なさそうですね...

海外のフォーラムで見たところ、パーティクルでGUIが消える問題についてのトピックがりました。
https://forum.yoyogames.com/index.php?threads/issue-with-gui-flashing-or-disappearing.84276/

どうやらpart_system_depthが影響しているらしいです。
ただそこまでしかわかりませんでした../

9

ありがとうございます!トピックみて調べてみます。

7
yakata 2021/09/18 (土) 23:51:12

キャプチャとってきましたこの部分で大丈夫でしょうか。
ただFPSは1000~3000で激しく変動しているようです。FPSってこんなに高いんだけっけ…(お恥ずかしいことに見方が分かってない)

画像1
画像2
画像3

10

実fpsはゲームの実行fpsよりはるかに高いです。1000以上は十分高いので問題なさそうです。
debug_overlayの棒グラフ、赤と黄色の部分も負荷は低いので問題ないようですね。
テクスチャページとスワップが37,38で多めですが、これで表示が消えたりするのはたぶん無いと思います(私の経験では無いです)。
キャプチャの瞬間に限れば、負荷の問題はないようです。

8
asa 2021/09/18 (土) 23:51:12 修正

GUIイベントのコードを貼ることはできるでしょうか?

これは関係ないでしょうか。
https://forum.yoyogames.com/index.php?threads/particles-and-gui-gamemaker-1-4-9999-solved.52700/

11
yakata 2021/09/19 (日) 00:10:58

part_system_depth()消したら治りました…!ここが原因のようです

12
yakata 2021/09/19 (日) 00:18:18

消えていたUIの一つのGUIイベントです

if(global.raihau_bar_f=2){
draw_sprite_ext(spr_UI_raihau_bar_aa,0,0,0,1,1,0,c_white,1)
	//文字系 
	draw_set_font(fnt_mincho_test)
	draw_set_colour(c_black);	
	draw_text_transformed(240-string_width(global.raihau_txt)*0.5,1 ,global.raihau_txt,1,1,0);
}
13

part_system_depth()が関係してたんですね。直ってよかった!

14
yakata 2021/09/19 (日) 00:28:47

そうみたいです!
どうやってパーティクルのdepthを調整できるかはこれから考えますが大きく前進しましたありがとうございました!