安装 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(越南语)
Українська(乌克兰语)
报告翻译问题
if keyboard_check(ord("A"))
button = 0
if keyboard_check(ord("S"))
button = 1
if keyboard_check(ord("D"))
button = 2
Or whatever keys/ buttons you want. Then in the part with the stages you’d change them to something like:
if stage == 0
{
if button == 0
{
// attack version 1
countdown=30 // length of attack
}
if button == 1
{
// attack version 2
countdown=30 // length of attack
}
if button == 2
{
// attack version 3
countdown=30 // length of attack
}
stage+=1
}
Some people would say to use the “case” command when using this many ‘if’ statements, up to you what you use. If you want different attacks depending on the order you press the keys, that gets a bit more complex but I can help you with that if you want.
1) I have a question about GMS coding structure.
So let's say:
if place_meeting 1 pixel above a wall obj
{
X
if (A == 0)
{
do this
}
Y
}
If I also wanted to add something else like, play sound in the X or Y area, this applies to the 'if place_meeting 1 pixel above a wall obj' and not the 'if statement' within it, right?
2) Does the X or Y placement matter? Is X prioritized over the Y? Is coding above put at the top because it's more important?
3) Another question, how do you figure out why something's not happening when you don't get an error? (Is it think, and think hard? haha)
I've previously implemented double jumps in a previous project successfully so I'm using the same logic and coding in this project. The game works fine but the double jump just doesnt happen (as if I added nothing), so how do you figure out what you need to add or what you're missing? I kind of wish I would get an error so it can tell me but it has to be because i'm missing something, or maybe the placement of code is wrong, or something is conflicting with it.
Thanks again Almond.
Q2) Code runs from top to bottom, X would run first and then Y (but all in the same step) in this scenario. For choosing one for the audio to play would normally not matter.
Q3) Normally in cases like this I draw the variables that are involved so I can see in more details what is going on. I also use show_message to make a message pop up when something is meant to happen, it is useful because it pauses the game. You can also use show_message to show you a specified variable for that one step. I am going to assume that you have set up a variable so that there is a limited amount of jumps. I would check to see if it gets reset when the player lands and that both the normal ground jump and the mid-air jump are not used in the one button press.
I hope this helps.
The troubleshooting: You draw the variables as in figuratively or literally? Is it possible to only use the show_message when I want it to as in a simple code to add or remove when I'm trying to fix something/a bug?
If you recall, the enemy attack throws a bone and when collides with the player 3 times the player dies. Easy stuff because drag n drop. How would I make an enemy that does a melee attack? My player attacks draws a hitbox, I assume it would be similar. Can you elaborate on the steps I would need to do?
As for the drawing variables, I do mean literally. Say you have a countdown variable for something to happen, then you can put in its draw event:
draw_text(x-64,y-64,countdown)
That way you can watch the countdown variable. It should turn it into a string if it is the only variable you put it there, otherwise you would have to use string(). For example:
draw_text(x-64,y-64,"Countdown: " + string(countdown) + "#Cooldown: " + string(cooldown))
For the melee attack, that can be as complex as you want it to be. You could simply use the same code you used for the bone throw as just make it shorter range. You could use the same code you have for the player’s melee attack instead. Whatever you choose, you’ll probably need to do a couple of things.
Check the distance to the player
Check which way to attack
Add a gap between attacks
The distance check is not difficult. I know you already know this but I’ll but it here anyway. You can use distance_to_object or point_distance (my preference). As for the direction of the attack, a lot of platformers have enemies attack in only two ways (left and right). To find which way you can use something along the lines of:
sign(Player.x – Enemy.x)
Which will give -1 if the player is to the left of the enemy, 1 if to the right and 0 if they share the exact same x value. For the gap, you can add a cooldown variable that counts down every step. Once it reaches zero if the conditions are met (such as distance to player and if they are on the ground) it will pick an attack if it has multiple, execute that attack and reset the cooldown (different attacks can have different cooldowns based on the time the attack takes and how long you would like the gap between attacks is). I am happy to go through this in more detail if you would like.
Right now I'm trying to use my player attack and hitbox coding for the enemy attacks for more versatility in attacks and so the player can dodge attacks... I feel as though using the bone coding but shorter is like a guaranteed hit on the player?
If you feel it is too much of a certainty there are a few things you can do. I suggest you could add a little something that indicates when the enemy is about to attack. Something small like the enemy stops for a split second, or an animation or sprite change would work too.
How would I add invincibility frames after getting attacked?
I’ll give you two suggestions to choose from for the invincibility. The first one is to have a variable the player hold which indicates the player is invincible. At the start of every event that would damage the player it checks whether the variable is set to true or not. If it is false, it runs the normal code plus it set the variable to true and sets and alarm. If true, nothing happens. The alarm then sets the variable back to false again.
The second is to use a parent object for the player and the children are different states the player can be in. One for normal, one for invincibility and if you want you can add one each for climbing or swimming or whatever. This way you can have different controls for each state and still have enemies and objects treat them all the same (including distance checks and collisions if you want).
I think the first one might suit you better, it is neat, simple and works well. From what I’ve heard most people prefer to have it all in one object rather than splitting it and using the parent method. That said, I thought I’d suggest it anyway in case you think you should use it.
I replied to your question in the other discussion you posted.
This is in the colliding with bone code in case I did something wrong here:
if (invincible = false)
{
health -= 35;
invincible = true;
alarm[1] = 100;
}
Also, how can I make it so the bones only disappear when it hits and subtracts health from player?
draw_text(x,y,alarm[1]);
As for removing the bone only when not invincible, one way is to put the code within the player object, in their collision with the bone event. For example:
if (invincible == false)
{
health -= 35;
invincible = true;
alarm[1] = 100;
with other
{
instance_destroy();
//other codes the bone may have had
}
}
Do not forget to remove the bone’s collision event if you are going this way.
The other one would be that in the alarm event it both resets itself AND does not set invincible to false; that is if you had it so it sets it to true or you had a different variable, for example invisible instead of invincible (It would likely not cause an error because you are setting the variable and not addressing it). Seems unlikely but I recommend double checking.