memoryGraphics.drawImage(img,this.x,this.y,this.width,this.height,null);
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.lovo.game.util;
import java.awt.MediaTracker;
import com.lovo.game.role.Fire;
import com.lovo.game.role.GameMap;
import com.lovo.game.role.ZhaoYun;
public class TrackerInit {
public static void initImage(MediaTracker tracker){
//初始化地图图片
GameMap.mapImg = CutImage.getSingleImage("image/map.jpg", tracker);
//赵云
ZhaoYun.zyImage = CutImage.cutOneImage("image/boss/playSpear.png",18, 236, 134,tracker);
//火
Fire.fireImage = CutImage.cutOneImage("image/fireImg.png", 6, 283, 161,tracker);
try {
//0组java人物上下跳动代码的图片全部等待加载完毕后java人物上下跳动代码 , 在显示
tracker.waitForID(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.lovo.game.util;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageProducer;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class CutImage {
public staticImage[][] cutManyImage(String filePath, int row, int col,
int imageWidth, int imageHight,MediaTracker tracker) {
Image[][] img = new Image[row][col];
ImageIcon imIcon = new ImageIcon(filePath);// 创建图像数组对象
Image imgTemp = imIcon.getImage();// 创建源图像
// 为源 图象获取ImageProducer源
ImageProducer sourceProducer = imgTemp.getSource();
for (int i = 0; irow; i++) {
for (int j = 0; jcol; j++) {
// 创建图片分割图像对象,第一、二个参数为分割图像起始坐标 。后两个参数为图像大小
CropImageFilter cropImg = new CropImageFilter(j * imageWidth, i * imageHight,imageWidth, imageHight);
ImageProducer imgProducer = new FilteredImageSource(sourceProducer, cropImg);
img[i][j] = new JFrame().createImage(imgProducer);
tracker.addImage(img[i][j], 0);
}
}
return img;
}
public staticImage[] cutOneImage(String filePath,int col,
int imageWidth, int imageHight,MediaTracker tracker) {
Image[] img = new Image[col];
ImageIcon imIcon = new ImageIcon(filePath);// 创建图像数组对象
Image imgTemp = imIcon.getImage();// 创建源图像
// 为源 图象获取ImageProducer源
ImageProducer sourceProducer = imgTemp.getSource();
for (int j = 0; jcol; j++) {
// 创建图片分割图像对象,第一、二个参数为分割图像起始坐标 。后两个参数为图像大小
CropImageFilter cropImg = new CropImageFilter(j * imageWidth, 0,imageWidth, imageHight);
ImageProducer imgProducer = new FilteredImageSource(sourceProducer, cropImg);
img[j] = new JFrame().createImage(imgProducer);
tracker.addImage(img[j], 0);
}
return img;
}
public static Image getSingleImage(String imgPath,MediaTracker tracker){
Image img = new ImageIcon(imgPath).getImage();
tracker.addImage(img, 0);
return img;
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.lovo.game.util;
import java.awt.Image;
public class MoveImageChange {
private int count;
private Image img;
private int frequency;
private int loopCount;
public MoveImageChange(int frequency){
this.frequency=frequency;
推荐阅读
- linux中各命令的意义,linux各种命令
- zblog插件原理,zblog插件破解插件
- 软件刚开直播电视,打开直播电视
- go语言slice使用 go语言strconv
- 关于c语言设计车辆限行的信息
- 欧版p40pro可以升级鸿蒙吗,欧版p40pro在国内可以用5g吗
- 宝宝巴士游戏老鼠大冒险,宝宝巴士小老鼠乡下老鼠
- 关于vb.net视频百度云盘的信息
- 魔幻车神什么视频能看,魔幻车神的影视