GameMaker Studio 2 - How To Import & Animate Sprites Beginner Tutorial
Вставка
- Опубліковано 5 кві 2017
- Check out the updated video: • GameMaker Studio 2.3 -...
Learn to import and animate sprites in GameMaker Studio 2. Perfect for beginners or those upgrading to GMS 2.
In this video I'll walk you through a blank project to having a fully animated character using a sprite sheet and GameMaker Language. We'll animate very smoothly, learn how to adjust animations based on movement speed, and set the game to 60 FPS over the default 30 for buttery smooth animations.
My Exclusive Courses💻🎮:
- Bundle Course Package & More Here! www.letslearnthistogether.com...
Social:
- Connect with me on Twitter @Aaron_LLTT: / aaron_lltt
- Become a valued Patron and receive more exclusive perks @: / letslearnthistogether
- Wanna hear from other developers in the industry? Head on over to my podcast, DevTalk, to listen to engaging conversations I have with various successful developers: devtalk.buzzsprout.com/
Finished Project With Comments ------ drive.google.com/open?id=0B8h...
Updated 2020 version of this⬆ video here 👉: ua-cam.com/video/po8TMV9y9SE/v-deo.html
Thank you so much!
You just saved me. I know this video was posted six years ago, but I just spent over an hour trying to figure this out and your video finally helped. Thank you so much.
I was just getting a start on gamemaker studio for fun, but man... you cover lots of subjects regarding game coding and you just mention what are very essential. Your videos are very explanatory and easily understandable. Really nice work you're putting on this channel. I really like the videos and hope the best for you, Good luck ^^
Thank you ! I was struggling to import animated sprites ! I had to use photoshop to edit them and stuff, now i know exactly how to do it simply ! UR THE BEST YO
Finally a tutorial where after lauching game the movement worked
This video saved my butt for a game designing class! Thank you so much!
It is people like you that, not only make learning fun, but also "Make Learning"!!!! Thanks also for the generousity of the sprites and full project. Like others, I learn best when I pull a project to pieces and put it back together after knowing what each piece does.
+3dmonkeybizz I am happy to hear you're learning and that what I'm putting out is being used.
That was super helpful , Thank you so much for making this video! I was struggling so much with this , now this whole thing is just soo much easier
Hey dude, just found your channel and wanted to tell you that you are the best teacher on this damn website.
+aceraven Thanks for the compliment, I appreciate it!
Hi I'm trying to make a game and I have a Sprite that has a green background how do I get rid of the green background and only have the Sprite
+black star23 When you import the sprite it should have a checkbox to clear the background. If not, inside the image editor you can color select a background away with one of the tools.
Your an idiot. This is not a website.
@@ahmadfallah700 ... UA-cam... is TOTALLY... a website.
Dude you are Awesome!! For some reason i was having trouble in my code, so i change "walk_Speed" for "WalkSpeed" in the event, and works for me. Keep it up!
This is EXACTLY what i needed, thx a lot, just subbed
thanks! this is just what i was looking for!
Brilliant! Clear and concise!
Amazing video, straight forward and useful. really helped me out through my Uni project.
Simple, and very helpful; Thanks a lot! ^^
Thanks a lot for this tutorial. It help me very much for a game I write for my daughter. Adding the sprite sheet and the project is more than appreciate since it's easier to debug with a working template!
You're very welcome. It's awesome you're making a game for your daughter, as I'm actually working on the same kind of thing. Have great fun with it!
Thank you so so much!
Definitely got another subscriber today! Amazing videos good sir! Have a grand day!
+TheExiledJester and to you good sir!
This is the best video i've watched. Thanks
Thank you so much dude! This helped a lot!
THANK YOU this is the best Tutorial site subscribed
so much thanks dude. Cool video and good explanation
You helped me a lot with that. Thanks
good job guy! thanks!
this helped me so much thx :)
Thanks, this really helped me.
Thank you very much for this amazing tutorial :)
Great video!
thanks a lot man! I made sure to make notes of these certain actions that you can type within GML and exactly what they mean. The only problem is I couldn't find a symmetric sprite sheet for Samus but still made the best of it, thank you again!
thanks really helped me out on this one !!!!!
Amazing honestly , thank you✨💯
Really insightfull tutorial for me as a newcomer to GameMaker community
Teacher for Life bro. Thanks!
Perfect, thank you !!
ive bin looking for this tutorial for so long THANK YOU!!!!!!!
*I've
*been
no one cares Mnooper -_-
One of the best videos!
O God this dude is really helpful love you
I *cant wait to start making more serious games*
Great job! Thx
*Thanks **dude.My** computer not working and i watched this tutorial on another computer.But next week i'm call the pc fixer for fix my computer*
Awesome, thanks :)
thank you so much!!
OH MY GOD BROH, thank you
i got it to work thanks (i just modified it just because i wanted "D" and "A" , i will need to think how to make a jump but i think i got this) thanks
your the best thanks for the help
genial, por fin un video bien explicado, thank you so much
*Thanks* *a* *lot!* *I* *can* *finally* *animate* *phew*
Y E S thank you this helped me so much.
thanks :D
I just looked Shaun Spaldings complete Game programming, but he only works with image_index = 0, 1, 2 etc. And not with sprites, so you saved me :)
Where you were in my tutorials!? New suscriber to you!
very very helpsul now i request u to make video on jumping and fighting ( attualy how do i get the frame of fihting and jumping i dont have them i only have walking and running and right and left plzzz i request and u are a good teacher also
thanks alot remember you can use for the running If keyboard_check_pressed(vk_shift) i think
I'm not sure if anyone mentioned this, but (in Gamemaker Studio 1 at least) using this code if you press the shift key while walking and then let go of it, but NOT of the WASD then your character will keep running. I simply did this to fix this:
if (keyboard_check(vk_shift)) {
walkSpeed = 7;
};
else {
walkSpeed = 3.5;
};
Also, you get my thumbs up for this exceptional tutorial. I wanted to get into this program, but any tutorials I could find were plain bad. I hope I'm not gonna run into problems using GM1, but I will follow these tutorials anyway :)
@EDIT: Actually using this method there is another problem. If you press the shift key while walking and let go of the WASD keys, but NOT of Shift, your character will keep its walking animation even though it's walking. The code is also easily fixed, what you do is replace this line:
if (keyboard_check(vk_nokey)) {
with this:
if (!keyboard_check(ord("W")) && !keyboard_check(ord("S")) && !keyboard_check(ord("A")) && !keyboard_check(ord("D"))) {
+Konradix05 code wise, the programs aren't too different. If you look around, you'll find the fixes necessary. And that's something I should have covered originally, and just didn't. Nice work.
TY
Best tutorial i've watched, can you please help me if i want it with the arrow keys? Thanks a lot keep up the good work.
+Nyong Atienza Arrow keys are pretty simple. They are virtual keys, checked with the constants vk_direction. So try this:
If(keyboard_check(vk_right)
//right movement code.
And so forth.
like it !
Thanks✓
Just tip for you guys and girls:
If the no key method doesn't work in stopping your character from moving, use another key to stop your character from moving. That's the alternative. For me, it for some reason won't stop my character from moving even though I followed every direction step by step in the video.
I used "Z" as a solution.
if keyboard_check(ord("Z")) {
image_speed = 0;
image_index = 0;
walkSpeed = 3.5;
}
Update: I didn't space the if keyboard line..but anyways at least there is a alternative if you don't want to use the no key method.
Hey, good video, thanks! I did try downloading your sprite sheet at first though, and when imported, it left a white background, instead of a transparent one (which is also how it appears on the hosting website). I don't know if that problem was with you, the hosting website, or with how I downloaded it? I ended up finding another image (which I still had to import into GIMP to make IT load without a background) and used it to practice with. I was wondering if there's a better way though. I tried the color removal tool, but it was going pixel by pixel.
Anyway, good video though, and thanks for making it! I look forward to perusing your other tutorials.
if you downloaded it as a jpeg, it will be white. pngs normally register transparency
How do I animate different directional movement in a "left click to move" scenario? I can't set "W,A,S,D" keys to each animation because im using a single left click to determine direction
what do you do if spreadsheet animated sprites arent the same size (so you can just make all boxes the same size you have to make each a different size)
This video is a life saver!
I have a character who has an idle animation for four different directions. This is the code I currently have (I tweaked it a little from your example):
if (keyboard_check(vk_nokey))
{
sprite_index = spr_champion_front_idle;
}
How would I set it for every direction?
Inside that if statement, add another series of checks for your current direction. Then based on that direction set the correct sprite.
If you don’t have a variable, just set one on each other key press of movement.
um I want to know how to make a smash bros type of moveset because this game for steam called rivals of aether is a platform fighter like smash so I would like to know how to do that specifically pls
Hello! What do you usually use to make your sprites? I'm trying to find a good template and program to use for my game, and I usually do my own art for it. Any recommendations?
Aesprite and spriter I’ve heard good things about. I don’t create my own art, I just find free or pay for it.
I just made my first sprite now I got the idle done I have to make him run and jump so this helps
You can check it out on my page lol it's funny I think
I have a question. So, I did everything on the video except for running then I ran a test run but my sprite flew offscreen. Can you tell me what I am missing or what I did wrong?
Great video! I have a question, if W+D, the speed of the diagonal, how to solve?
Others have asked that, and I've I've given some answers, try and find them on here. I believe you just need to add some more checks for multiple buttons, and slow down the speed overall.
Okay thank you
Hey, I have a run button for my character, when you hold down shift and press any key they run, when you let go of shift she returns to default speed and image speed, however if I am holding shift and any arrow key, then let go of the key and continue holding shift she endlessly cycles through the walk cycle until I let go of shift, do you know how to fix this?
+egosactor .co You could add some keyboard_check_released events or code in the step event, to check for the arrow keys specifically.
Or have a check if only the shift key is being held down, to stop the animating.
okay thanks I'll look up released events then because I don't know how to do that yet lol, and when I tried having a check for just the shift key I set the image speed to 0 so when I held down shift the character just slid around the screen without any animation, maybe I did it wrong? Regardless thanks
The problem from to : if(keyboard_check(vk_nokey))
{
image_speed = 0;
image_index = 0;
walkSpeed= 3.5;
}
Cause if I hold enter, the game see me press another key so he didnt stop the animation
I use this to fix the problem :
if(keyboard_check_released(ord("D")))
{
image_speed = 0;
image_index = 0;
walkSpeed= 3.5;
}
if(keyboard_check_released(ord("Q")))
{
image_speed = 0;
image_index = 0;
walkSpeed= 3.5;
}
if(keyboard_check_released(ord("S")))
{
image_speed = 0;
image_index = 0;
walkSpeed= 3.5;
}
if(keyboard_check_released(ord("Z")))
{
image_speed = 0;
image_index = 0;
walkSpeed= 3.5;
}
// Don't try to do this
if(keyboard_check_released(ord("D"))) || (ord("Q")) || (ord("S")) || (ord("Z"))
{
image_speed = 0;
image_index = 0;
walkSpeed= 3.5;
}
//You're animation will not activate when you gonna press ZQSD keys
Also, if you do Light's solution, one more problem comes up in that the game wont reset your walk speed to 3.5 until you release all the keys. The result is that pressing shift once while walking will lock you into running until you stop pressing any keys, making it impossible to to go from a run to a walk without stopping. One solution is this:
if(keyboard_check_released(vk_shift)) {
walkSpeed = 3.5;
}
Thanks for the help, but I have a question. How do you mirror sprites?
Depending on how you want to mirror them, flip the x or y coordinate with it's negative opposite.
So to flip a walking right sprite to left, multiply its image x by -1.
Hello. I'm using my own custom sprites as I go along with this tutorial. How do I set a frame to be the "standing still" frame? (there's 2 frames, 1 for looking down, the other for looking up) Please and thank you.
+StonedApe Start by counting from 0 for the image_index for your sprite and set that to be the standing still frame when you stop moving your character.
when i import the character i still can't get rid of that white background around the character animation, and when i import the character in game, it shows it with that white background....
Question from the future, is there any way i can just create a key down event and then use a begin step for the animation?
Sure. It sounds like you just do what you said.
I'm with a problem , my sprite turns into a square when i run the game , in the program he's normal but when i run the game he turns into a square . What do i do ?
Nice tutorial video. Need some guidance. I downloaded the file as png, however, when I imported as strip image, the background stays as white. Is there anything that I missed? Thanks.
No, sometimes it does that. If you click on the colour remove tool and select the background, that will remove it.
Hey, what video would you recommend for learning how to make dialogue boxes? I want to add some text to my game.
I'd recommend my series: ua-cam.com/video/_4c2l6jXjDw/v-deo.html
The first two will show you how to set up just dialogue boxes to be used in any kind of situation, The last 3 will show you how to have full conversations in your games.
Thanks a TON dude! Not only do you have good videos, but you are the first game maker tutorial maker that actually answers my questions, and with helpful replies. Thanks!
Thanks for tutorial. For 8 direction movement, not only 4 like in videos, just add example:
if keyboard_check(ord ("W")) && keyboard_check(ord("D"))
{
sprite_index = moveDiagonalRight; (or how you name a sprite for top right movement)
}
right? Or there is a simple way?
+Ярослав Соллер Yeah, that would work. If you use just if statements for the movement, you'll move in all 8 directions, but you do need specific if checks to change their sprite like you have.
Can you import a sprite strip as a layer into another sprite? Say I go into the image editor, create new layer, and I want to import an already finished strip that I have saved as a PNG that will be drawn over top of the default layer.
+B r a n d o n I'm not sure I totally understand your question, but I don't think so. I think you'd need to edit the image in another program, like Gimp, to get what you're looking for.
On the create part it says variable walk speed only referenced once????? Help please
Huge thanks m8.
One question can I somehow make sprint on V with ord its pretty buggy and I dont want shift to be running.
You can change any of the controls to whatever makes sense.
@@LetsLearnThisTogether When I use ord and press the key I made it onto it will make my character move to the right and it wont stop even if I let go. Why is that?
Sounds like a logic error you’ve got, as the code is working. If you’re using the built in speed property to set your movement, you must set it back to 0 otherwise you’ll always keep moving.
If you have a different system, you probably need a keyboard_check_released on your v character so you can set your move speed back to 0.
@@LetsLearnThisTogether ok thx
@@LetsLearnThisTogether helped me a lot
How do I make the idle sprite animated? I have the front idle animation working, but whenever I stop it reverts to that.
When your character isn't moving, like when no input is being pressed, set image_speed to 1 and set your sprite to idle. If your idle sprite has an animation, it will play.
i have a question, theres a game which uses files with the .gmspr extension and i was wondering how to export my sprite animation into that extension
I don’t think that extension is used in GMS2, though previous iterations did use it. From what I looked up, that’s just the way the sprite files are saved by default, you can’t export them or anything.
when you are walking and press shift one time , and key up shieft while you keep walking, sara keep fast.
so i create 2 if's, one for key_pressed other to key_realesed , and change speed based on this.
+Lucas Almeida Yeah, that works, too.
Question: I'm making a video project that will use some short animated pixel art cut scenes to help tell the story. I'm commissioning a lot of the sprite sheets and background art, but I'm not sure which program would be best to stage and record the animations. Would I have to use GameMaker Studio 2 to code them all in and then, perform and record, or could I get this done in After Effects or some other program?
Unless they've changed it, GMS doesn't easily allow you to add outside videos into your games. Do some research on that, because if you can't add them in, you'll need to do it in code so it's just like the game is playing itself for the cut scene.
@@LetsLearnThisTogether Thank you, I'll check into.
I have some questions, I hope you could help me.
Why my background is white? I'm not sure if that is bad, but how could I make it transparent? And, is better make a sprite on a transparent background in a first place?
I'd recommend going to open game art and downloading the Sprite directly.
If you're using your own, you can use the color remove tool to get rid of a specific color on your Sprite once it's in the editor.
If your sprite only switches sides but doesnt animate make sure you wrote image_speed correctly
I just started my attempt at recreating a game. I'm not familiar with coding, so I'm basically making use of the drag and drop features to initiate events. Do you have the same tutorial animating sprites using the drag and drop feature?
+Shawn Mika I don't, although many have asked. It's something I'll look into adding. GML is more powerful, but I understand coding can be intimidating.
My knowledge of coding is next to nothing...ok, it's nothing.. One of the thing that attracted me to GameMaker studio was the ability to use the drag and drop system. I've been able to figure out a few things on my own, but it's getting to the point where I'm getting stuck on very basic actions. Thank you for any help, It's appreciated.
+Shawn Mika I've got a series on here for people with no programming experience, actually 2. One goes over coding basics using GML, and the other uses the drag and drop system to create a platform game, then I go step by step into converting that into code. You should check them out.
Thank you so much! It's a great help.
Thank you so much!
I have problem how to make colision at the same time could you add colisions to this project?
I’ve got more videos on collision, check out my channel.
Hello, I am having trouble with the left and right walk animations. When I press right, Sara moves but the animation is stuck on the frame of her stepping (She still moves). I have the same problem with the left walk animation. Another problem is that I have a white backround on (not the whole screen)my sprite.
As far as the animations, are you increasing the image index? Download my project and compare my code to yours, to double check you’ve got it all right.
You can remove a color in the sprite editor, choosing the remove color and clicking on the white.
man....I was really hoping there would be a way to just import multiple images to make a single animation like I used to do in GM5. I really don't want to have to take the time to get them all perfectly placed together on a single sheet
How can I make it that when I press two buttons (like D first and then W, or W and S at the same time), the character sprite either uses an another one (when I press D first and then W, my sprite turns to the top, but I want it to turn right) or the animation stops? (pressing W and S, or D and A makes it run in one place)
The way you code your movement system effects this. If you use only if statements, then multiples of them can trigger, causing your player to not run when pressing opposite keys. If you use if, else if statements, then only one will trigger. Add an else before your if statements, after the first, and you should see the difference.
Well... Coding is "kinda" difficult 😅 I don't really know where to write else, or what should I write. Like, I have this code:
/// Walk right
if(keyboard_check(ord("D")) and place_free(x +collisionSpeed, y)) {
x += walkSpeed;
image_speed = walkSpeed / 3;
sprite_index = spr_lily_right_walk;
}
What should I add? Something like this?:
else
if(keyboard_check(ord("A"))) {
}
Image speed? Sprite index?
Beyond Us Games can will you do a tutorial when you create a sprite from the start, save the sprite and create the animation? Please I need to know the program for do sprites. I use Asprite but Asprite don?t export his files in gamemaker
+This is the amazing world of MP3 I can certainly add it to the list.
Hey! This vid is great. But when I go to play my character walks right no matter what key I press. Does anyone know how to fix this?
Paste your movement code on here. My guess is you copied and pasted the x += for the rest of the movement and that’s why you’re always moving right.
is there other software for creating sprite sheets, and whats the normal size for pixel art and vector graphics in games.
There’s lots of software, really any drawing program can be used, but there are many specifically made for 2D sprites. Look it up and you’ll find lots, I don’t have much experience with them.
As for sizes, totally depends on your game. I prefer the 32 bit look, but many use 8 bit for super old school.
@@LetsLearnThisTogether cool, thank you
I love this tutorial, but for some reason, in my step code, every close curly bracket is an error. What should I do?
nevermind, i fixed it.
@@canchrisget500subswithcomm8 I’m having the same problem, what did you do to fix it???
I have a question, if I have multiple sprites and I want them to all be in one animation, how would I do that?
When I import a new frame it replaces the original sprite instead of adding a frame.
I wouldn’t suggest having different animations in one sprite, but if you’re set on it, then bring them in as separate. Then you can select the frames from one sprite, copy them, and paste them into another.
@@LetsLearnThisTogether thank you!
If I'm going to make sprites and animate them then it would be better to use graphicsgale instead of the sprites generator in game maker studio 2. Now this is the reason: in graphicsgale when creating a sprite you can see a somewhat transparent image of the previous frame so that you can use it as a guide to draw the next frame and you can watch the image animate live as you create your sprite.
That feature is called onioning (I think), and is also available in GMS. However, I'd suggest creating sprites in a third party program, like graphicsgale, as it allows more flexibility and freedom. If you make the sprites in GMS, they're stuck there forever, but in other programs you can export them to other places.
Do i HAVE to import sprites or can i just make multiple in game maker?
Please answer as quick as possible
I havent touched my game cause i didnt know if it worked without being imported or not
And if it doesnt work without importing in GameMaker, where did you make the sprites?
You can absolutely make all the sprites in GameMaker. Importing them is just the only way to get outside sprites into your game, but you can make everything in GMS as well.
When i press A to go left it uses the left sprite but i go right, i have the code to go left but it doesn't
+FusionDjango Double check your brackets, as those can cause an issue if they're not aligned properly. Download my project and compare it to yours as well, and you might see the problem right away.
Hey, first of all gr8 tutorial!! But I have an issue! When I start the game with my character in (im not using Sara!) When I press the letter "A" the character like teleports up in the screen, super weird and I cant fix it, maybe you know the problem and can help me?
How much does it teleport? If it’s only a little, then ensure that your sprite origins are all centered.
If that’s correct, you’ll need to check your code because it sounds like you’re setting an x or y value instead of adding to it.
@@LetsLearnThisTogether Yea, after I wrote that comment I saw the problem, so I fixed it!