站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题人物跳的问题!!!!

人物跳的问题!!!!

摘要: 人物跳的问题!!!!


做个一超级马力的游戏!,我按了跳(UP)后,,他不肯下来了。。
我在松开键后设定每次循环少3个象素,直到碰到地面为止。。可是我现在按了跳以后他就只减3个象素然后停那了

求助~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


这是你逻辑的问题,自己调试一下就好了


自己开发的游戏,还会这样???


wo 也不知道怎么回事啊/!!!!!!!!!!!!


乱了,乱了,,一起乱吧~~



你循环的代码怎么写的,贴出来看看,光说谁知道问题在哪里



又让我碰到了,哎


import java.io.IOException;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class GameCanvas extends Canvas implements Runnable
{
// ImageUtil iu = ImageUtil.getInstace();
SuperMaryMidlet midlet;
Image title[]= new Image[5];
Image movemary[] = new Image[10];
int translatex=0;
int translatey=0;
int maryx=10,maryy=105;
int rightmarycurrent ,leftmarycurrent,movemarycurrent;
int speed=0;
boolean moveUP = false,moveDOWN = false,moveRIGHT = false,moveLEFT = false;
public GameCanvas(SuperMaryMidlet midlet){
super();
this.midlet=midlet;
this.setFullScreenMode(true);
try {
for(int i =1;i<6;i++)
{
title[i-1]=/* iu */Image.createImage("/res/"+i+".png");
}
} catch (IOException e) {
e.printStackTrace();
}
try {
for (int i = 1;i<11;i++)
{
movemary[i-1]=Image.createImage("/res/penguin"+i+".png");
}
}catch (IOException e) {
e.printStackTrace();
}
Thread t = new Thread(this);
t.start();
}
protected void paint(Graphics g) {
g.setColor(0);
g.fillRect(0,0,getWidth(),getHeight());
g.translate(translatex,translatey);
for(int i1 =0 ;i1for(int j =0;j{
if(Data.map0[i1][j] == 0)
continue;
g.drawImage(title[Data.map0[i1][j]-1],j*10,i1*10,0);
}
g.drawImage(movemary[movemarycurrent],maryx,maryy,0);
}
public void keyPressed(int key)
{
int keycode=getGameAction(key);
switch(keycode)
{
case UP:
moveUP = true;
break;
case DOWN:
moveDOWN = true;
break;
case LEFT:
moveLEFT = true;
break;
case RIGHT:
moveRIGHT = true;
break;
}
}
public void keyReleased(int key)
{
moveUP = false;
moveDOWN = false;
moveLEFT = false;
moveRIGHT = false;

}
public void releasedmove()
{
//if(moveUP == false )
// {
//maryy+=3;
// }
//if (moveRIGHT == false)
//{
//maryx++;
//}
//if (moveLEFT == false)
//{
//maryx--;
//}

}
public void moveMAP()
{
if(moveUP == true)
{
movemarycurrent = 8;
translatey+=5;
maryy-=5;
}
//if(moveDOWN == true)
//translatey++;
if(moveLEFT == true)
{
translatex+=5;
maryx-=5;
if(movemarycurrent>=5)
movemarycurrent=3;
else
movemarycurrent++;
}
if(moveRIGHT == true)
{
translatex-=5;
maryx+=5;
if(movemarycurrent>=2)
movemarycurrent=0;
else
movemarycurrent++;
}
}
public void run() {
while(true){
moveMAP();
if (moveUP == false)
{
int fx,fy;
fx = maryx/10;
fy = maryy/10;
while(Data.map0[fy][fx] == 0)
{

System.out.println("s");
maryy+=3;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fy = maryy/10;
repaint();
}
}
repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

}
现在不按就减少象素
就是一进游戏就往下降几个象素
然后没按一次键也是下降几个象素
到底该怎么处理这个跳啊


使用 int key=getKeyStatu()

if key==UP_PRESS&&more
{
more=false;
........
}
else
{

more=true;
}





if (moveUP == false)
{
int fx,fy;
fx = (maryx+15)/10;
fy = (maryy+15)/10;
while(Data.map0[fy][fx] == 0)
{
System.out.println("s");
maryy+=3;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fy = (maryy+15)/10;;
repaint();
}
}

你的fx = maryx/10;
fy = maryy/10;
必须加上你的那个人的高度


wo 要不要把分散给你啊
老大!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


↑返回目录
前一篇: 关于蓝牙的问题,在线等,在实际两台手机中实现蓝牙传输时,进行一次连接后就自动断开的问题?
后一篇: 技术讨论——J2ME编程中是否需要面向对象?