简体   繁体   English

Java-像素数组未从另一个类渲染另一个类

[英]Java - Pixel array not rendering from another class another class

I am experimenting with game development in java. 我正在尝试用Java开发游戏。 As of now, I can use the screen class to render to the Canvas of an image through pixel array. 到目前为止,我可以使用screen类通过像素数组将其渲染为图像的Canvas。 However, whenever I attempt to render to the canvas through the pixel array within the other class, it reads the pixels array's content. 但是,每当我尝试通过另一个类中的像素数组渲染到画布时,它都会读取像素数组的内容。 xy numbers and all but, does not render it to the canvas at all even though the other class extends the screen class (thus inheriting the pixels array and the x, y numbers). xy数字和所有其他字符,即使另一个类扩展了屏幕类(因此继承了pixels数组和x,y数字),也根本不会将其呈现到画布上。 What is causing this? 是什么原因造成的? How do I go about fixing it? 我该如何解决?

from the other class: 从另一类:

void origin(){

    if(x <= ax && y <= ay)
        pixels[ox + oy * width] = 0xff00ff;
    }

From the screen class: 从屏幕类:

void waves(){
    orga = new Organism(width, height);

    for(y = 0; y < height; y++){
        for(x = 0; x < width; x++){

            Color wacol = new Color(0, 0, u);
            int water = wacol.getRGB();

            pixels[x + y * width] = water;
            orga.origin();
        }
    }
}

扩展类还不够,它必须以与像素阵列相同的方式连接到屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM