小编use*_*507的帖子

为什么矩形跳跃的高度会有所不同?

为什么矩形跳跃的高度会有所不同?它似乎进入了一个循环.首先它跳低然后它根本不跳,然后它跳高然后它根本不跳.我无法弄清楚为什么使用相同的代码并且它由同一事件触发.

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;


@SuppressWarnings("serial")
 class Game extends JPanel{
Square square = new Square(this);
 Ground ground = new Ground (this);
public Game() {
    addKeyListener(new KeyListener() {
        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            square.keyReleased(e);
        }

        @Override
        public void keyPressed(KeyEvent e) {
            square.keyPressed(e);
        }

    });
    setFocusable(true);
}
public static void main(String[] args) throws InterruptedException {

    JFrame …
Run Code Online (Sandbox Code Playgroud)

java graphics animation swing game-physics

1
推荐指数
1
解决办法
178
查看次数

奇怪的Java异常名称

我做了一个System.out.print,其对象为null,我得到了这个:

550270261027054028026002805302902590290520300258030051031025703105003202560320
490330255033048034025403404703502530350460360252036045037025103704403802500380
43039024903904204002480Exception
Run Code Online (Sandbox Code Playgroud)

我试过谷歌搜索它,但例外的名称太长了.

有谁知道这个例外意味着什么?

for (int i = bulletList.size(); i > 0; i--) {
        final Bullet b = bulletList.get(i - 1);/* the bullet is just a class containing it's image, its position and its rectangle and handling its movement*/
        b.r = new Rectangle(b.x, b.y, 34, 20);
        for (i = obsticalList.size(); i > 0; i--) {
            final Obstical o = obsticalList.get(i - 1);//Obsical class is like the bullet class but for stationary thing
            System.out.print(o.r.x);
            System.out.print(b.r.x);//This is where I get …
Run Code Online (Sandbox Code Playgroud)

java exception

0
推荐指数
1
解决办法
404
查看次数

标签 统计

java ×2

animation ×1

exception ×1

game-physics ×1

graphics ×1

swing ×1