English 中文(简体)
java Slick 2D 如何设置颜色
原标题:java Slick 2D how to set color
  • 时间:2012-05-24 12:52:37
  •  标签:
  • slick2d

我疯狂地想画一个非常简单的直肠和一个文字 以便了解它是如何与 浮滑的2D Java 图书馆合作的

这就是我要尝试的:

g.setColor(Color.green);
g.fillRect(50, 50, 50 ,50);

g.setColor(Color.orange);
g.drawString("Write something", 100, 100);

只要我画的一切 绿色或橙色, 但没有一个绿色 和另一个橙色, 因为我想做的...

有人能帮我弄清楚吗?

事先多多谢感谢

问题回答

Your code seems to be correct, and works on my test-game. Are you running it in the appropriate method, public void render(GameContainer gc, Graphics g)?

试着更新您的 LWJGL 和 Slick2D 库 。

想象一下您手工重新绘制屏幕。 你拿起绿色笔, 绘制矩形。 然后拿起橙色笔, 绘制单词。 这就是您告诉 Slick2D 用您的代码做的。 不要改变两个绘图操作之间的颜色, 只需设置颜色, 然后画出两个对象, 然后它们会以相同的颜色出来 。

当您更改所有形状/ 文本操作的颜色时, 之后的操作将会以该颜色进行, 直到您再次更改颜色 。

我还在导入 java.awt.cool; , 这个图书馆与 Slick2D 不符 。

import java.awt.color; 改为 import org.newdawn.slick.color;





相关问题
Slick2d Can t find image even though it s in the right area

I m following the tutorials found on the Slick2D website, and upon loading Images to my program, I get an error that says: Tue Nov 01 14:12:47 EDT 2011 INFO:Slick Build #274 Tue Nov 01 14:12:47 EDT ...

Java LWJGL custom texture

I m working on a smallish game with a friend and we ran into a really annoying problem with sprite sheets and textures... Right now we re just using Slick2D s textureloader and we even tried their ...

Slick2D Movement Issue

So, I converted a game to Slick2D. The movement is broke, and I am at a loss. Before, we used KeyPressed and keyReleased methods, but now with Slick2D movement isn t working right. Yea, nothing has ...

Zooming in Slick2D

I m working on a really low res game that I need to zoom in to make it visible. I know I can use Graphics.scale(float x, float y) but I d like to zoom into the center. How can I scale the Graphics ...

Variable Timesteps and Gravity/Friction

I m trying to copy the logic of the Sonic physics engine, which was written for a fixed-timestep system (60 FPS), in a variable timestep age (Slick2D, to be precise). In the original upon pressing ...

热门标签