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.
@lktee314510 жыл бұрын
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; } }
@keiththerice77139 жыл бұрын
lk tee Thanks, I needed this. CougarkillZ This'll help you out.
@woodsjuden74957 жыл бұрын
It's been four years. Always gets a lot of things. Thank you. It really helps a lot.
@keiththerice77139 жыл бұрын
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);
@keiththerice77139 жыл бұрын
never mind, I figured it out.
@jb954678 жыл бұрын
+Keith TheRice Whenever you solve a problem, you are morally obligated to post your solution as well.
@wasabidesu10 жыл бұрын
what does g.DrawImage(btm, Point.Empty) do?
@dabestharpis11 жыл бұрын
Hi, can you please post the code for this?
@Cougarkillz10 жыл бұрын
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.
@hajiamano2210 жыл бұрын
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.
@Cougarkillz10 жыл бұрын
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
@hajiamano2210 жыл бұрын
CougarkillZ Might wanna save it to a file. Its set to stay there for a week. But Good luck and Np.
@russsharp37676 жыл бұрын
The video is so blurry, I can't even see any(!) of the code.
@21madalin8 жыл бұрын
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'
@jessnguy8 жыл бұрын
I think its cause you're missing : Using.System.Drawing; at the top where the rest of the using is at