有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java数组来显示图像,但是需要创建另一个方法来选择显示多少次

我在标题中可怕地解释了这一点,我很抱歉,我对java非常陌生,还不太了解其中的一些内容

无论如何,我的cat动画运行到屏幕中间,刮两次,然后继续运行到最后,是否有任何方法将int num作为参数,使neko刮x次数取决于输入

任何帮助都将不胜感激

这是我目前的代码

// Run the animation. 
public void nekoRun() {
    moveIn();
    scratch();
    //scratch2(5);
    moveOut();
}

// Move Neko to the centre of the panel
private void moveIn() {
    for (int i = 0; i < getWidth()/2; i+=10) {
        xPos = i;
        // swap images
        if (currentImage == nekoPics[0]) 
            currentImage = nekoPics[1];
        else 
            currentImage = nekoPics[0];
        repaint();
        pause(150);
    }   
}
    //neko stops and scratches in the middle of the panel twice
private void scratch() {
    for (int i = 0; i < 10; i++)  {


        // Swap images.
        currentImageIndex = nextImageList[currentImageIndex];
        currentImage = nekoPics[currentImageIndex];


            repaint();
            pause(150);
        }
}
//Neko runs to the end of the panel
private void moveOut() {
    for (int i = xPos; i < getWidth(); i+=10) {
        xPos = i;
        // swap images
        if (currentImage == nekoPics[0]) 
            currentImage = nekoPics[1];

        else 
            currentImage = nekoPics[0];
        repaint();
        pause(150);
    }   
}

共 (0) 个答案