C# Graphics Simple Animation Tutorial

  Рет қаралды 47,108

Brandon Hilde

Brandon Hilde

Күн бұрын

Пікірлер: 19
@BrandonHilde129
@BrandonHilde129 9 жыл бұрын
Hey guys I know it can be difficult to find all the code in the video. I no longer have this code it has been almost 2 years. But all the code necessary to run this is visible in the video and it looks like someone has posted it in the comments as well. So you should be able to find everything that you need.
@lktee3145
@lktee3145 10 жыл бұрын
Form1 code public partial class Form1 : Form { public Form1() { InitializeComponent(); } Animation animate; Graphics g; Graphics scG; Timer t; Bitmap btm; private void Form1_Load(object sender, EventArgs e) { g = this.CreateGraphics(); btm = new Bitmap(this.Width, this.Height); scG = Graphics.FromImage(btm); t= new Timer(); t.Interval = 110; t.Tick += new EventHandler(t_Tick); animate = new Animation(new Bitmap[] {Properties.Resources.Image1,Properties.Resources.Image2}); } void t_Tick(object sender, EventArgs e) { scG.Clear(Color.Black); scG.DrawImage(animate.GiveNextImage(), new Point(20, 60)); g.DrawImage(btm, Point.Empty); } private void button1_Click(object sender, EventArgs e) { t.Start(); } private void button2_Click(object sender, EventArgs e) { t.Stop(); } } Animation Class code public class Animation { Bitmap[] images; int place = 0; public Animation(Bitmap[] frames) { images = frames; } public Bitmap GiveNextImage() { Bitmap b = images[place++]; if (place >= images.Length) { place = 0; } return b; } }
@keiththerice7713
@keiththerice7713 9 жыл бұрын
lk tee Thanks, I needed this. CougarkillZ This'll help you out.
@woodsjuden7495
@woodsjuden7495 7 жыл бұрын
It's been four years. Always gets a lot of things. Thank you. It really helps a lot.
@keiththerice7713
@keiththerice7713 9 жыл бұрын
Thanks for the video, my last problem is how do you change the size of the animated images? Edit: Problem solved *This line* scG.DrawImage(animate.GiveNextImage(), new Point(20, 60)); *to this* scG.DrawImage(animate.GiveNextImage(), 20, 60, width, height);
@keiththerice7713
@keiththerice7713 9 жыл бұрын
never mind, I figured it out.
@jb95467
@jb95467 8 жыл бұрын
+Keith TheRice Whenever you solve a problem, you are morally obligated to post your solution as well.
@wasabidesu
@wasabidesu 10 жыл бұрын
what does g.DrawImage(btm, Point.Empty) do?
@dabestharpis
@dabestharpis 11 жыл бұрын
Hi, can you please post the code for this?
@Cougarkillz
@Cougarkillz 10 жыл бұрын
I like the tutorial, but only half the code is shown so I can't figure out wtf you did to make it all work. Trying to recreate it is impossible.
@hajiamano22
@hajiamano22 10 жыл бұрын
To create a animation you Split the image up (if done from a sprite sheet) Then you store it in a array. Run through all the images. So it would like this pastebin.com/dwjk64c3. There are some game tutorials on my channel but I don't think I covered animation.
@Cougarkillz
@Cougarkillz 10 жыл бұрын
Butler Studios I get the theory of how it's done, But half of the code in this specific tutorial is hidden. I was trying to recreate the exact thing they did, but can't just because not all the code is shown. It's a tutorial, so instead of going back and showing the 6 images 3-4 different times, it would be better to show the code used to animate the images. But thanks or that link, I bookmarked that page for future reference =-b
@hajiamano22
@hajiamano22 10 жыл бұрын
CougarkillZ Might wanna save it to a file. Its set to stay there for a week. But Good luck and Np.
@russsharp3767
@russsharp3767 6 жыл бұрын
The video is so blurry, I can't even see any(!) of the code.
@21madalin
@21madalin 8 жыл бұрын
i get these errors but i dont know why the code is exactly like yours .Can you help me ? Error 1 Cannot implicitly convert type 'System.Drawing.Bitmap' to 'System.Drawing.Bitmap[]' Error 2 The best overloaded method match for 'System.Drawing.Graphics.DrawImage(System.Drawing.Image, System.Drawing.PointF)' has some invalid arguments Error 3 Argument 1: cannot convert from 'System.Drawing.Bitmap[]' to 'System.Drawing.Image'
@jessnguy
@jessnguy 8 жыл бұрын
I think its cause you're missing : Using.System.Drawing; at the top where the rest of the using is at
@marcelocarvalho0910
@marcelocarvalho0910 9 жыл бұрын
good job
@BrandonHilde129
@BrandonHilde129 9 жыл бұрын
Thanks!
@kevinlin6937
@kevinlin6937 6 жыл бұрын
so i meet evil spirits.
C# Programming - Drawing Using The Graphics Class
19:56
Bill Butterfield
Рет қаралды 84 М.
Animation - WPF TUTORIAL
16:47
SingletonSean
Рет қаралды 28 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Visual C# Game Skills 1 - Basic Animation
8:35
OnlineLearningCS
Рет қаралды 20 М.
C# how to create a simple graphic editor - part 1
19:54
Dawisko1
Рет қаралды 96 М.
Game Development in x86 Assembly Language - Draw Rectangle
13:28
Brandon Hilde
Рет қаралды 2,6 М.
C# Animated Rain Loading Form | Timer
20:50
CodeFlow
Рет қаралды 49 М.
Where are types allocated in .NET and why people get it so wrong
14:35
Qt Calculator GUI Tutorial Part 1
15:02
Programming Liftoff
Рет қаралды 136 М.
How To Code A Web Scraper In C#  | Programming Tutorial For Beginners
12:06
C# How to Use Paint and the C# Graphics Class to Draw Lines
37:36
Chris Merritt
Рет қаралды 198 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН