Continue, taking into account the future expansion of the need to start the code modular refactoring, the original Mypanel decomposed into Common,gamemap,gamehandle and Mypanel and other 4 modules, step-by-step sprite operation.
0-5 The source download address is as follows, has been packaged.
Http://www.3adisk.com/?onlinezero
File name: [Rpgchair]
or save this x GIF file as a RAR format.
As there is no change, do not say more, I continue to be depressed today, what all ignore, continue to be depressed ...
Common class :
package org.loon.chair.example5;
/**
*
* @author Chenpeng
* @email ceponline@yahoo.com.cn
*
* Loon Framework in Game
*
*/
Public Interface Common {
Here we add a set of constants to distinguish the triggering of the left and right buttons,
The reason why we use numbers to make a difference is that everyone is very clear ^ ^, digital
The efficiency of the operation is high ~
Public Static Final int left = 0;
Public Static Final int right = 1;
Public Static Final int up = 2;
Public Static Final int down = 3;
Single image size, I default to 32x32 graphics, can adjust the scale as needed.
At that time, always should be coordinated with the size of the form, such as 32x32 pictures, how to
Set 15 on one line, then 480, which is the default form size for this example,
Of course, we can also automatically adjust the initialization of the ROW*CS,COL*CS according to the
The size of the form will be used in a future example. In a word, programming
is [for the purpose of existence], all methods, everyone can try and use.
Public Static Final int CS = 32;
}
Gamemap class:
package org.loon.chair.example5;
import java.awt.Graphics;
import java.awt.Image;
import Javax.swing.ImageIcon;
/**
*
* @author Chenpeng
* @email ceponline@yahoo.com.cn
*
* Loon Framework in Game