本文整理汇总了Java中javax.microedition.lcdui.Graphics.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawImage方法的具体用法?Java Graphics.drawImage怎么用?Java Graphics.drawImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Graphics
的用法示例。
在下文中一共展示了Graphics.drawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DrawGif
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ��GIFͼ��
* @param imgpath ͼ��·��
* @param x x����
* @param y y����
*/
private void DrawGif(String imgpath,int x,int y)
{
Graphics g=getGraphics();
if(imgpath!=prepath)
{
prepath=imgpath; //�ѵ�ǰͼ��·������ǰһ��
gifd.read(this.getClass().getResourceAsStream(imgpath));//����ͼƬ
framecount= gifd.getFrameCount();//��ȡ֡��
}
for(int i=0;i<framecount;i++)
{
g.drawImage(gifd.getFrame(i), x, y, anchor);
try {
Thread.sleep(FrameInterval);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
flushGraphics();
}
}
示例2: ShowLift
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ������ͷ
* @param n Ҫ���ĸ���
*/
private void ShowLift(int n)
{
System.out.println("��ʾ������...");
int startpos=0;
Graphics grap=getGraphics();
if(n!=3)
{
//����ǻ�����˵���dz�ʼ��,����������Ҫ�������
grap.drawImage(liftbg, 0, 0, anchor); ///����ͷ�������
}
for(int i=1;i<=n;i++)
{
grap.drawImage(lift, startpos, 0, anchor); //ÿ�λ�һ������17����
startpos+=17;
}
flushGraphics();
}
示例3: ShowLightBg
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ��ʾ��ɫ�ĵ�
* @param state ����״̬
* @param n ��ʾ������
*/
private void ShowLightBg(Light state,int n)
{
Graphics gra=getGraphics();
gra.drawImage(passarea, 0, py, anchor); //���±���
int startpos=0;
for(int i=1;i<=n;i++)
{
if(state==Light.dark)
{
gra.drawImage(passbg, startpos, py, anchor);
}
startpos+=15; //ˮƽƫ��һ��ͼƬ��
}
flushGraphics();
}
示例4: init
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ���������ʼ��
* @param score ����
* @throws IOException
*/
public void init(int score) throws IOException
{
/*��Ϸ����:42,23
gameover:42,38
������:38,58
����ͼƬ:45,107*/
gameovertip=Image.createImage("/gameovertip.GIF");
endtip=Image.createImage("/endtip.GIF");
scorebg=Image.createImage("/scorebg.GIF");
gameoverbg=Image.createImage("/gameoverbg.GIF");
Graphics gra=super.getGraphics();
gra.setColor(255, 255, 255);
gra.fillRect(0, 0, sw, sh);
gra.drawImage(endtip, 42, 23,Graphics.LEFT|Graphics.TOP);
gra.drawImage(gameovertip, 42, 38,Graphics.LEFT|Graphics.TOP);
gra.drawImage(scorebg, 38, 58,Graphics.LEFT|Graphics.TOP);
gra.drawImage(gameoverbg, 45, 107,Graphics.LEFT|Graphics.TOP);
flushGraphics();
repaint();
super.ShowScore(score);
System.out.println("��������������");
}
示例5: ShowLift
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ������ͷ
* @param n Ҫ���ĸ���
*/
private void ShowLift(int n)
{
int startpos=0;
Graphics grap=getGraphics();
if(n!=3)
{
//����ǻ�����˵���dz�ʼ��,����������Ҫ�������
grap.drawImage(liftbg, 0, 0, anchor); ///����ͷ�������
}
for(int i=1;i<=n;i++)
{
grap.drawImage(lift, startpos, 0, anchor); //ÿ�λ�һ������17����
startpos+=17;
}
flushGraphics();
}
示例6: Fail
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ���˶���ʧ��
*/
private void Fail()
{
ShowLightBg(Light.dark, ActionCount);//���а�ɫ�Ʊ���
Graphics gra=getGraphics();
int startpos=0;
for(int i=1;i<=rightcount;i++)
{
gra.drawImage(pass, startpos, py, anchor);
startpos+=15;
}
gra.drawImage(notpass, 15*rightcount, py, anchor); //���ƴ����
flushGraphics();
currentLift--; //��������1
ShowLift(currentLift); //��ʾ������
if(currentLift==0)
{
//GameOver
Gameover();
}
else
{
CurrentPressindex=ActionCount; //ʹС����������
}
}
示例7: doRight
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ���˶������Ե�ָʾ
* @param n ���ԵĴ���
*/
private void doRight(int n)
{
int startpos=0;
Graphics gra=getGraphics();
for(int i=1;i<=n;i++)
{
gra.drawImage(pass, startpos, py, anchor);
startpos+=15;//ˮƽƫ��һ��ͼƬ��
}
for(int i=1;i<=ActionCount-n;i++)
{
gra.drawImage(passbg, startpos, py, anchor);
}
flushGraphics();
}
示例8: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
int y = 0;
String loginStatus = "";
if (session.isLoggedIn()) {
loginStatus = "Logged in as " + session.getUsername();
}
else {
loginStatus = "Not logged in";
}
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_TEXT);
g.drawString(loginStatus, w - H_SPACE * 2, y, Graphics.TOP
| Graphics.RIGHT);
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
if (separatorImage != null) {
y = height - separatorImage.getHeight() - V_SPACE;
g.drawImage(separatorImage, 0, y, Graphics.TOP | Graphics.LEFT);
}
}
示例9: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
g.setFont(FONT);
final int y = V_SPACE * 2;
final int fontOffset = FONT.getHeight() / 2;
final int vote = item.getVote();
final int leftX = H_SPACE * 2;
final int rightX = w - 2 * H_SPACE;
g.drawImage(vote == -1 ? voteDownActiveImage : voteDownImage, leftX, y,
Graphics.TOP | Graphics.LEFT);
g.drawImage(vote == 1 ? voteUpActiveImage : voteUpImage, rightX, y,
Graphics.TOP | Graphics.RIGHT);
g.drawString("Vote down", leftX + voteImageWidth + H_SPACE, y
+ fontOffset, Graphics.TOP | Graphics.LEFT);
g.drawString("Vote up", rightX - voteImageWidth - H_SPACE, y
+ fontOffset, Graphics.TOP | Graphics.RIGHT);
}
示例10: init
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ��Ϸ��ʼ��
*/
private void init(boolean hasreadhistory)
{
if(hasreadhistory)
{
try
{
System.out.println("��ʼ��ȡ�ϴ���Ϸ��¼...");
readhistory();
if(currentLift<=0)
{
currentScore=0;
ActionCount=2;
ActionRepeat=6;
currentLift=3;
}
System.out.println("��Ϸ��¼��ȡ���...");
}
catch(Exception e)
{
//�����ع�
currentScore=0;
ActionCount=2;
ActionRepeat=6;
currentLift=3;
System.out.println("��ʼ��ʱ��ȡrmsʧ��..."+e);
}
}
Graphics gra=getGraphics();
gra.drawImage(bg, 0, 0, anchor); //����
ShowLift(currentLift);//����������ͷ
ShowScore(currentScore); //
flushGraphics();
}
示例11: DrawOld
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* �����˶���
* @param dir ����
*/
private void DrawOld(Dir dir)
{
Graphics gra=getGraphics();
int x=sw-o1.getWidth();
if(dir==Dir.d1)
{
gra.drawImage(o1, x, oy, anchor);
}
else if(dir==Dir.d3)
{
gra.drawImage(o3, x, oy, anchor);
}
else if(dir==Dir.d7)
{
gra.drawImage(o7, x, oy, anchor);
}
else if(dir==Dir.d9)
{
gra.drawImage(o9, x, oy, anchor);
}
else if(dir==Dir.ready)
{
gra.drawImage(oready, x, oy, anchor);
}
flushGraphics();
}
示例12: Fail
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ���˶���ʧ��
*/
private void Fail()
{
System.out.println("���˶���ʧ��...");
if(exit)
{
//������û������ؼ�����ʧ��,�����������
System.out.println("�û��˳�����ʧ��...");
return;
}
ShowLightBg(Light.dark, ActionCount);//���а�ɫ�Ʊ���
Graphics gra=getGraphics();
int startpos=0;
for(int i=1;i<=rightcount;i++)
{
gra.drawImage(pass, startpos, py, anchor);
startpos+=15;
}
gra.drawImage(notpass, 15*rightcount, py, anchor); //���ƴ����
flushGraphics();
currentLift--; //��������1
if(currentLift==0)
{
//GameOver
Gameover();
}
else
{
ShowLift(currentLift); //��ʾ������
CurrentPressindex=ActionCount; //ʹС����������
}
}
示例13: doRight
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ���˶������Ե�ָʾ
* @param n ���ԵĴ���
*/
private void doRight(int n)
{
System.out.println("����������ʾ...");
ispass=getClass().getResourceAsStream("/pass.wav");
try
{
Play(ispass, 1);
}
catch(Exception e)
{
System.out.println("��������ʧ��:"+e);
}
currentScore++;
ShowScore(currentScore);
int startpos=0;
Graphics gra=getGraphics();
for(int i=1;i<=n;i++)
{
gra.drawImage(pass, startpos, py, anchor);
startpos+=15;//ˮƽƫ��һ��ͼƬ��
}
for(int i=1;i<=ActionCount-n;i++)
{
gra.drawImage(passbg, startpos, py, anchor);
}
flushGraphics();
}
示例14: init
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ��Ϸ��ʼ��
*/
private void init()
{
Graphics gra=getGraphics();
gra.drawImage(bg, 0, 0, anchor); //����
ShowLift(3);//����������ͷ
ShowScore(0);
flushGraphics();
}
示例15: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
listener.onPaint(graphics);
if (isLandscape) {
g.drawRegion(image, 0, 0, width, height, Sprite.TRANS_ROT90,
0, 0, Graphics.TOP | Graphics.LEFT);
} else {
g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
}
}