我一直在阅读David Brackeen 的《用 Java 开发游戏》。到现在为止我已经明白了书中的所有内容。在 Wavefront 对象文件中,我理解该v命令的作用,但不理解该f命令。例如:
# OBJ - Wavefront object file
# The javagamebook loader only understands these commands:
# mtllib <filename> - Load materials from an external .mtl
# file.
# v <x> <y> <z> - Define a vertex with floating-point
# coords (x,y,z).
# f <v1> <v2> <v3> ... - Define a new face. a face is a flat,
# convex polygon with vertices in
# counter-clockwise order. Positive
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试验证网址.这是我的代码:
function isValidURL($url)
{
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
Run Code Online (Sandbox Code Playgroud)
这段代码正在运行,但现在我正在尝试解决如何添加http://或者https://如果URL正确但只是错过了开头http://
请指出我正确的方向.
我的问题是,当我点击框架屏幕的空间时,它会停止键盘键被注册,所以我的播放器停止移动.
在此先感谢您的帮助.
代码:
private Component comp;
....
public InputManager(Component comp) {
this.comp = comp;
mouseLocation = new Point();
centerLocation = new Point();
// register key and mouse listeners
comp.addKeyListener(this);
comp.addMouseListener(this);
comp.addMouseMotionListener(this);
comp.addMouseWheelListener(this);
// allow input of the TAB key and other keys normally
// used for focus traversal
comp.setFocusTraversalKeysEnabled(false);
}
Run Code Online (Sandbox Code Playgroud)
GUI代码:
Game game = new Game();
game.setMinimumSize(new Dimension(WIDTH * 2, HEIGHT * 2));
game.setPreferredSize(new Dimension(WIDTH * 2, HEIGHT * 2));
game.setMaximumSize(new Dimension(WIDTH * 2, HEIGHT * 2));
frame = new …Run Code Online (Sandbox Code Playgroud)