42 videos
238 minutes
As you can see I have already put the code in full screen mode because the introductions are over. It's time to start programming seriously. As you can see the code is empty, because I've removed before giving record, because I am smart sometimes. also deletes the sample code because we're going to do a much better, you'll see. First of all, I will stop in ApplicationAdapter and why MainGame should extend to
ApplicationAdapter. That's because as you saw in doing the project for Android, desktop, whatever, you have a number of pitchers and creators, the desktop or Android, it seems that already do the job for us. Application really we do is not ours. The application is libgdx. What we do is write over the code but who prepares the audio system, video system,
entry system is libgdx and therefore is really libgdx who pilots the application below. What we do for convenience is to give control of the application to change that might happen in the constructor of the application, for example when we desktop application or when creating the application on mobile phones, our MainGame. And the MainGame it really is a class
Application Type: ApplicationAdapter or ApplicationListener. The convenience is that in exchange for giving libgdx control application, libgdx ensures that call a number of methods that have in the game, at opportune moments. This is the code ApplicationAdapter, and these are the six methods: create, resize, render, pause, resume and dispose. I will not stop to show how they work all methods
because it seems a little beast. For now I'll explain the two most important'll use from the following video to upload images, and then as they are using, why not, let's see what each of them. The first method I think is important is the create method. The create method, which is the method that will run libgdx for us automatically when you have finished preparing all these systems
of which you spoke. This is where we would have to upload images, sounds, resources ... in short, prepare the game to make it presentable. And here someone say 'jo, Dani, we have a thing called constructor, I do not know if you remember.' It is dangerous to put critical code, such as loading images or file upload in the constructor because maybe libgdx has still not prepared these systems, such as file upload system,
because ultimately it depends on one platform or another how can upload files. Think of a web browser, you can not upload files so easily. Or on mobile phones it becomes different depending on whether you are Android or iOS. Or desktop can access more files that can be mobile. That kind of thing, as libgdx the need to study separately is more dangerous to do if you do it before libgdx know how.
In the constructor only begin ArrayLists, HashMaps, basic classes of Java but nothing that is critical must be in the constructor, that should be in the create. Here we charge things in the next episode or what has to be loaded later. The second method Most important is the render. The render method is important because it is the one we use to represent the application or to update the status of the game.
libgdx ensuring is that it will run the render method about 30 or 60 times each second, depending on the speed that has the device. Through this method show images on screen, if you have to update the status of the game, such as updating the position of a character to make it appear that moves linearly. This is the method we use to represent that kind of thing. When you load the images we'll use
to render all that we have loaded. But first, let's focus on how to load those images.
About the Author
Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.