[TUTORIAL] Creating class in J2ME SDK Mobile - Printable Version +- dedomil.net - Mobile Games Forum (http://dedomil.net/forum) +-- Forum: Off Topic Section (/forumdisplay.php?fid=3) +--- Forum: Off Topic discussion (/forumdisplay.php?fid=4) +--- Thread: [TUTORIAL] Creating class in J2ME SDK Mobile (/showthread.php?tid=5626) |
[TUTORIAL] Creating class in J2ME SDK Mobile - JoseskVolpe - 05-20-2021 09:26 PM ¿What is J2ME SDK Mobile? J2ME SDK Mobile is a tool that lets you create Java ME games and applications in your phone, without the need of a PC. You can see more informations and download it here: [APP] J2ME SDK Mobile Introduction I've had received some messages that correlates with the "¿how do i begin?" issue. It's about how do you create a new class in your project ¿What are classes? First, Java is a object-oriented programming, and it works by polimorphism It means that you can script a object a single time, and then just extend it to change some of it's attributes Polimorphism So, for example, if i wanna create a NPC J2ME native's libraries has a Sprite class. So i could extend it to make it as Sprite class So, i can create a new .java file with this code. J2ME SDK Mobile will already partially generate this code when i create a new class Code: package my.game.package; Additionally, i can now create a Ally, Player and Zombie class with their own variables, extending any feature i can create on my parent classes. So, if i modify my NPC class. Both my Ally, Zombie and Player classes will extend these modifications easier and faster to program, avoiding the need to script the same thing many times. Player: Code: package my.game.packages.npcs; Ally: Code: package my.game.packages.npcs; Zombie: Code: package my.game.packages.npcs; From this, i've created this structure:
Creating a new class tutorial
Errata I cannot edit it, so i'll levae it here I've wrote it: Code: public damage(int hpLoss){ It's wrong, because damage() is a method, and is written as a constructor We should do this instead: Code: public void damage(int hpLoss){ |