I can Make android Game wow 🙆
Let's learn to code, publish your own game in playstore and start earning.
You may know about about Android studio. And I hope you may know about Java, if not then no problem. Lets' get started...
First of all download Eclipse from trusted site
Open up Eclipse and create a Java project. You can do this by right clicking on the Package Explorer >> New >> Java Project:
Call it GoNu
(consistency will ensure that we won't have errors due to naming). Also
the JRE version can be either 1.6 or 1.7. It does not matter!
Inside this project's src folder (remember this is where we store all our code):
1. Create a Package. Name it GoNu. By convention its the package name begins lowercase.
Packages are ways of organizing classes into folder-like structures.
Right click on your newly created package and create a class: StartingClass.
1. Create a Package. Name it GoNu. By convention its the package name begins lowercase.
Packages are ways of organizing classes into folder-like structures.
Right click on your newly created package and create a class: StartingClass.
KiloboltGame Project containing a kiloboltgame Package containing a StartingClass class.
Now we can start coding.
Lesson #2-2: Adding Methods and extending Applet
By this time, I trust that you are all experienced Java programmers capable of discerning which brace corresponds with which.
As such I will no longer be color coding unless I believe it is absolutely necessary.
1. Add extends Applet after "StartingClass". Recall that we can borrow methods from a superclass by inheriting it.
2. You will see a red line under Applet. Import Applet by pressing Ctrl+Shift+O or by manually selecting the import by mouseover.
3. You can now add the following methods: init(), start(), stop(), destroy(). These are part of the Applet superclass, and by importing Applet, you gain the ability to use them.
4. An easy way to add a pre-defined method (as in one that is already written for you), is to use the auto-complete function. Begin typing "init" and then press Ctrl + Space. It will open an auto-complete suggestions box, from which you can choose the first init() function. Proceed to do this with all four methods and you will see this:
Lesson #2-2: Adding Methods and extending Applet
By this time, I trust that you are all experienced Java programmers capable of discerning which brace corresponds with which.
As such I will no longer be color coding unless I believe it is absolutely necessary.
1. Add extends Applet after "StartingClass". Recall that we can borrow methods from a superclass by inheriting it.
2. You will see a red line under Applet. Import Applet by pressing Ctrl+Shift+O or by manually selecting the import by mouseover.
3. You can now add the following methods: init(), start(), stop(), destroy(). These are part of the Applet superclass, and by importing Applet, you gain the ability to use them.
4. An easy way to add a pre-defined method (as in one that is already written for you), is to use the auto-complete function. Begin typing "init" and then press Ctrl + Space. It will open an auto-complete suggestions box, from which you can choose the first init() function. Proceed to do this with all four methods and you will see this:
5. Press Ctrl + Shift + F to auto-organize your code.
Shortcuts such as these will help you save a lot of time.
Shortcuts such as these will help you save a lot of time.
package GoNu; import java.applet.Applet; public class StartingClass extends Applet { @Override public void init() { // TODO Auto-generated method stub super.init(); } @Override public void start() { // TODO Auto-generated method stub super.start(); } @Override public void stop() { // TODO Auto-generated method stub super.stop(); } @Override public void destroy() { // TODO Auto-generated method stub super.destroy(); } }
The four methods: init(), start(), stop(), and destroy() are frameworks for execution provided by the Applet class. In this Applet's life cycle, major events will call one of these methods and execute it.
The @Override tests for errors upon compilation. In this case, we are using it to annotate that we are overriding methods from a parent class. It informs you when you make mistakes.
Within each method, you will see a "super." This "super" is referring to the superclass (in this case Applet). You might also see a "this" in the future, which will refer to the current class. Don't worry about this for now. We can safely delete each "super" line (or leave it, if you choose):
Day 2
No comments:
Post a Comment
If you have any doubt, let me know...