【2D】ゲーム作成ツールGameMaker part3【マンセー】
■ このスレッドは過去ログ倉庫に格納されています
0016名前は開発中のものです。
2008/05/12(月) 00:15:01ID:Nz3aygB6条件にあるxとyの値が決め打ちなのも意味不明。
君がやりたいことは、
・マウスの方向によって画像を変更する
なのだろう?
なら、「マウスの方向」が条件になるはずではないか。マウスの座標は mouse_x mouse_y で知ることができる。
そして、自キャラから見たマウスの方向は、point_direction() という関数で知ることができる。
アイコンによる設定の説明は面倒なので、コードだけ書いとく。(Varアクションと TestExpression でできるけど)
ステップイベントにExecute Code アクションを追加して、中身を下のやつをコピペしてみ。
spr_k001_xx は向きにあわせたものに直してくれ。
direction = floor(point_direction(x,y,mouse_x,mouse_y)+22.5);
if (direction>=0 && direction <45) { //右向き
sprite_index = spr_k001_xx;
} else if (direction>=45 && direction <90) { //右上
sprite_index = spr_k001_xx;
} else if (direction>=90 && direction <135) { //上
sprite_index = spr_k001_xx;
} else if (direction>=135 && direction <180) { //左上
sprite_index = spr_k001_xx;
} else if (direction>=180 && direction <225) { //左
sprite_index = spr_k001_xx;
} else if (direction>=225 && direction <270) { //左下
sprite_index = spr_k001_xx;
} else if (direction>=270 && direction <315) { //下
sprite_index = spr_k001_xx;
} else if (direction>=315 && direction <360) { //右下
sprite_index = spr_k001_xx;
}
■ このスレッドは過去ログ倉庫に格納されています