Steamをインストール
ログイン
|
言語
简体中文(簡体字中国語)
繁體中文(繁体字中国語)
한국어 (韓国語)
ไทย (タイ語)
български (ブルガリア語)
Čeština(チェコ語)
Dansk (デンマーク語)
Deutsch (ドイツ語)
English (英語)
Español - España (スペイン語 - スペイン)
Español - Latinoamérica (スペイン語 - ラテンアメリカ)
Ελληνικά (ギリシャ語)
Français (フランス語)
Italiano (イタリア語)
Bahasa Indonesia(インドネシア語)
Magyar(ハンガリー語)
Nederlands (オランダ語)
Norsk (ノルウェー語)
Polski (ポーランド語)
Português(ポルトガル語-ポルトガル)
Português - Brasil (ポルトガル語 - ブラジル)
Română(ルーマニア語)
Русский (ロシア語)
Suomi (フィンランド語)
Svenska (スウェーデン語)
Türkçe (トルコ語)
Tiếng Việt (ベトナム語)
Українська (ウクライナ語)
翻訳の問題を報告
Both player objects need to have their own health tracked individually. If you're using Game Maker's built in health variable, that thing is global, meaning it doesn't belong to any given object. You'll need your own varibale declared in the player object; it can just be Health and work fine, because GM is in fact case sensative.
From there, the easiest thing to do would probably be to have enemies and obstacles set to deal a specific amount of damage when they trigger a collision with the player objects; during collision events, there's a special term called other that works in code and is usually selectable in drag & drop that will automatically apply the action to whatever you've collided with.
So, for example, if a bullet has an event where it collides with the player and you want to remove 5 health, you could use the drag & drop's Variable command, select "Other" as the target, and set the player's HP to 5 less what it was by setting -5 for your value and checking "Relative." (Relative is important! It subtracts 5 from the present HP, whereas if it's left unchecked it wil just set the HP to -5.) After that, destroy the bullet, or it'll keep hitting your player every step until it passes through.
Alternatively, the same event with code would more or elss be like this:
You could aloso do your collision events in the player objects, but that's going to start stacking and getting unweildly very quickly, so it would probably be a lot wiser to have whatever's trying to inflict damage look for its target rather than the other way around.
Hope this helps.