我有一个代码:
# draw text
font = pygame.font.Font(None, 25)
text = font.render("You win!", True, BLACK)
screen.blit(text, [SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2])
Run Code Online (Sandbox Code Playgroud)
我如何获得像java中的文本宽度和高度方法,所以我可以将文本居中,如:
screen.blit(text, [SCREEN_WIDTH / 2 - text_w / 2, SCREEN_HEIGHT / 2 - text_h / 2])
Run Code Online (Sandbox Code Playgroud)
如果这是不可能的,那么另一种方式是什么?我找到了这个例子,但我并没有真正理解它.
我正在尝试编写一个方法,该方法对于给定的参数(值,颜色),在具有等于cellValue的值的单元格的背景上设置颜色.
我的方法实际上做的是,它为整行的单元格的背景设置颜色,当我选择表格上的行时,我希望方法只在每次特定列(其中cellValue等于值)设置颜色我叫这个方法.
void setCellBackgroundColor(boolean cellValue, final Color color) {
List<List<Object>> data = tView.getTTableModel().getData();
for (int row = 0; row < data.size(); row++) {
for (int col = 0; col < data.get(row).size(); col++) {
TableCellRenderer renderer = tView.table.getCellRenderer(row, Col);
Component component = tView.table.prepareRenderer(renderer, row, col);
boolean bValue =
TDataTypeRenderer.parseIntoRealValue(
data.get(row).get(col)
)
);
if (bValue == cellValue) {
component.setBackground(color);
}
}
Run Code Online (Sandbox Code Playgroud) 我成功安装了GlassFish.但是,当我启动服务器时,我收到以下两条警告消息:
警告:跳过条目,因为它不是绝对URI.
那是什么?
Launching GlassFish on Felix platform
Aug 09, 2014 10:38:38 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner
INFO: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
Aug 09, 2014 10:38:38 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
WARNING: Skipping entry because it is not an absolute URI.
Aug 09, 2014 10:38:38 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
WARNING: Skipping entry because it is not an absolute URI.
Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime@162cf6a in service registry.
Registry Info:: Total repositories: 1, Total modules = 293
...
Run Code Online (Sandbox Code Playgroud) 如下面的代码所示,我有一个基本的计时器系统
done = False
clock = pygame.time.Clock()
# Create an instance of the Game class
game = space_world.SpaceWorld()
# Main game loop
while not done:
# Process events (keystrokes, mouse clicks, etc)
done = game.process_events()
# Update object positions, check for collisions...
game.update()
# Render the current frame
game.render(screen)
# Pause for the next frame
clock.tick(30)
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何获取当前时间毫秒以及如何创建增量时间,因此可以在更新方法中使用它?
是否可以在 Ruby 中创建一个具有一种方法的模块(例如:计算 lcd 的数学方法),并将该方法包含到 Integer 类中,以便我可以在类似这样的事情之后执行
6.lcd(3)
Run Code Online (Sandbox Code Playgroud)
如果可以的话,我该如何包含它?