Frame Download Address: http://code.google.com/p/loon-simple/downloads/list
The following explains how to introduce the game framework Lgame in the project:
• Create a new Android project "LGameTest1", create a new folder in the root of the project Libs, place the jar package for the downloaded Lgame framework under that folder, right-click the project in Eclipse, and select Build Path->configure Build Path...->add External JARs ... "Select the jar package that you just put in the Libs folder so that the framework is introduced into the project."
• Establish a simple application, main program Files: Main.java, Testscreen.java, code to explain in the file.
Main.java files are as follows:
The code is as follows |
Copy Code |
Package org.loon.game.lgametest1;
Import org.loon.framework.android.game.LGameAndroid2DActivity;
public class Main extends Lgameandroid2dactivity {
@Override public void ongamepaused () { TODO auto-generated Method Stub
}
@Override public void ongameresumed () { TODO auto-generated Method Stub
}
@Override public void Onmain () { Set the game form size by default 320 * 480 (vertical), 480 * 320 (horizontal) Maxscreen (480, 800);
/** * Initialization is a lgame game form-level AdMob ad initialization function, when initialization is true, the game will be displayed in a horizontal screen, * Otherwise, the display position should be saved after the Maxscreen setting, and before other settings appear. In addition, in the initialization * You can also set the order of AdMob ads to show the location of the ads, the advertising ID, the keyword ads, as well as the frequency of the ad refresh * android:screenorientation= "Portrait" */ This.initialization (FALSE);
/** * Set the refresh speed of the game screen (this setting is valid only for the default standard screens Class) */ This.setfps (40);
Setting up a scene This.setscreen (New Testscreen ());
/** * Set the initial game logo is displayed */ This.setshowlogo (FALSE);
/** * Setting whether to display the game fps (only valid for standard screen) */ This.setshowfps (TRUE);
System.out.println ("Nieyanlong");
/** * Show Screen form */ This.showscreen (); }
} |
Testscreen.java files are as follows:
The code is as follows |
Copy Code |
Package org.loon.game.lgametest1;
Import Org.loon.framework.android.game.core.graphics.Screen; Import org.loon.framework.android.game.core.graphics.opengl.GLEx; Import Org.loon.framework.android.game.core.graphics.opengl.LTexture; Import Org.loon.framework.android.game.core.input.LTouch; Import Org.loon.framework.android.game.core.timer.LTimerContext;
Import Android.util.Log;
public class Testscreen extends screen {
Private ltexture[] images;
@Override public void OnLoad () { Record log LOG.D ("LGAMETEST1", "Here it is onLoad");
Ltexture.auto_linear (); Images = new Ltexture[1];
Assets Drop Resource File Images[0] = new Ltexture ("Assets/background.png"); Set background picture for current screen SetBackground (getImage (0));
Background music, "Main.mp3" files are placed under the assets folder Playassetsmusic ("Main.mp3", true); }
/** * Get Pictures * @param i * @return Ltexture */ Public ltexture getImage (int i) { return images[i]; }
@Override public void Alter (Ltimercontext arg0) { TODO auto-generated Method Stub
}
@Override public void Draw (Glex arg0) { TODO auto-generated Method Stub
}
@Override public void touchdown (Ltouch arg0) { TODO auto-generated Method Stub
}
@Override public void Touchmove (Ltouch arg0) { TODO auto-generated Method Stub
}
@Override public void TouchUp (Ltouch arg0) { TODO auto-generated Method Stub
} } |