

Animation is a big part of 2D games. If you want to create a video game, then you will have to learn how to make animation.
source
Animation is a big part of 2D games. If you want to create a video game, then you will have to learn how to make animation.
source
finally someone who talks to me like I was retarded, easy to understand tutorial, gg
8 years later. This' so cool
It's not working FOR MEEEEEE
WHYYYYYYYYYYYYYYY IT WON'T move!!!
Thank you so much
I learnt Java but the course didn't include animation
thanks
No its Ai will be teaching yuuu
A nice thing would be if u uploaded the whole code someehre
Thank you so much. You're the first person to mention repaint(). I've been looking for almost a week to find that.
fake, this code works differently.
How to animate with Colors and Timer?
sir when i used to implement ActionListener interface, an error is shown saying the class like here you have tutorial is not abstract in order to implement interface, when i create class as abstract. I cant run the code coz i can't make object of it. what should i do please?
Thank you ,great explanation
Thanx !
I have a Glitch in the animation , but I Use Ubuntu !! is there any solution Please ??
thanks
Simpler way even : https://youtu.be/_NEnhm9mgdE
is there a downloadable file for this?
how come when i write (public class tutorial extends JPanel implements ActionListener) always tell me that i have to make it abstract ? how can i disable it from becoming abstract ??
IT is not moving
Your tutotrial is pretty easy to understand !
Thanks!
could you please tell why this code
doesnt run on bluej. It just show me "tutorial is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent)in java.awhich.ActionListener"
Thx for the tutorial!
i like it
good tutorial, but pplease zoom out a little – need to see the whole thing.
And I thought my programming teachers were bad but this video must take the cake…
My rectangle is lagging when moving, is it normal ?
Here's the code guys:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;
public class Tutorial extends JPanel implements ActionListener{
Timer tm = new Timer(5, this); // 5 -> milliseconde, this -> ActionListener
int x = 0, velX = 2;
int y = 0, velY = 2;
public Tutorial(){
tm.start();
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.RED);
g.fillRect(x, y, 50, 30);
// tm.start(); // not optimal
}
public void actionPerformed(ActionEvent e){
if(x < 0 || x > 550)
velX = -velX;
if(y < 0 || y > 340)
velY = -velY;
y = y + velY;
x = x + velX;
repaint();
}
public static void main(String[] args) {
Tutorial t = new Tutorial();
JFrame jf = new JFrame();
jf.setSize(600, 400);
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setResizable(false);
jf.add(t);
}
}
it much more simple than i thought!
Instead of x = x + velX, you can use x += velX
You're big man 😀 Thank you for this tutorials, greetings from Poland!
thanks
Simple, easy and good video. I've been looking around on how to animate and the other sources made it unnecessarily hard to understand.
2:02
How do you move a rect with 2 clicks?
How to add another Rectangle > >? ? Is it possible Adding another Rectangle ??
+10
next time try to make the program from the begining………
What if I wanted what was drawn before to stay on the screen and for the screen NOT to be cleared?
Why it not work for me and it still says that the Tutorial is wrong and it has a red underline
Awesome tutorial. Thanks a million.
good video. 2 tips though.
1 if people don't know what interface implementation means, then they are not ready for animation programming, no need going through what implements means in what is supposed to be an intermediate subject.
2 The way you "moved" the X over in the Y slot and said "just imagine that it is a Y variable", just makes your instructions harder to understand, as well as making your code look less actual implementation of this functionality.
it took you more effort explaining your changes, than just adding the Y and velY would have been.
Dude I have tried it but it doesn't move it paints to the infinity instead of moving
Good tutorial, but how to add TWO moving rectangles to one JFrame? I tried it, and second rect, is overwritting the first one. I tried using JPanel but it doesn't work 🙁 Or i'm doing something wrong 🙁
What do you use to record?