- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我做了这些方法:
public Player(double x, double y){
this.x = x;
this.y = y;
ImageLoader loader = new ImageLoader();
SpriteSheet ss = new SpriteSheet(loader.loadImage("/Pics/TheSpriteSheet.png"));
this.image = ss.grabImage(1, 1, 32, 32);
}
public void tick(){
this.x++;
}
public void render(Graphics g){
g.drawImage(image, (int) x, (int) y, null);
}
然后我把它放在主类的 tick 方法中,它每纳秒左右被调用一次。
public void tick(){
playerClass.tick();
}
最佳答案
看起来您只是在更新 spaceship 的 x 位置,但并未重绘屏幕。因此,x 位置增加了,但您不会在屏幕上看到它!
您可能会使用类似spaceShip.repaint();
关于java - 我如何让我的 spaceship 移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30507786/
这个问题在这里已经有了答案: C++ Does not name to a type (2 个答案) 关闭 10 年前。 我正在开发一款小行星游戏,以此自学一些编程知识,但我遇到了一个错误,即我的一
这里是 Ship、Asteroids、BaseShapeClass 类的完整代码。 Ship Class 的形状继承自 BaseShapeClass。 Asteroid类是主要的源代码,它声明了Gra
我试图在基类中使用宇宙飞船运算符,所以我将通过编译器定义所有运算符。 (来源:https://devblogs.microsoft.com/cppblog/simplify-your-code-wit
我正在研究使用力、加速度和质量在笛卡尔 map 上进行点对点宇宙飞船旅行的一些逻辑。飞船将以 1G 的加速度加速燃烧至目的地,在中途标记处翻转 180 度,并以 1G 的加速度减速到达目的地的相对停靠
我做了这些方法: public Player(double x, double y){ this.x = x; this.y = y; ImageLoader loader =
我已经编写了一些代码来模拟带有单个推进器的船的无重力运动。大多数时候它都能正常工作,而且船会完美地到达目的地,但有时它会无限加速。但我想不通,为什么? seek(target) { var d
考虑这个代码: #include #include class A { public: int i = {}; std::strong_ordering operator (A const
我正在开发一款 Direct3D9 太空模拟器游戏,我需要在其中创建一个摄像机来保存玩家飞船的位置和视角。目前,我将我的代码限制为仅用于前后移动、上下移动以及扫射。下面是我的代码,它有问题。一切都包装
所以我是 Unity 的新手,昨天安装了 Unity 并且想制作一个简单的游戏来让自己入门......所以我试图让一个 3D 立方体在上下移动立方体的同时旋转。 我按照在线 2D 教程发现了我正在做的
Ruby 有一个叫做组合比较或“宇宙飞船”运算符的东西,它看起来像这样: 它执行以下操作: a b := if a b then return 1 Credit Javascript 中
一段时间以来,我一直在研究太空模拟游戏。起初,我使用自己的 3d 引擎和软件光栅器。 但是当实现纹理的时间到了时,我放弃了。现在我在一段时间后重新开始,现在我正在使用 Opengl(带有 SDL)来渲
我有以下代码: def sort_descending _objects, field _objects.sort { |b,a| a.send(field) b.send(field) } e
我需要按照以下逻辑对以下数组进行排序:如果“分数”相同,我想使用“时间”进行比较。数组如下: $user_scores = [ 82 => [ 'score' => 1, 'time' => 6.44
这个问题在这里已经有了答案: What is the ("spaceship", three-way comparison) operator in C++? (6 个回答) 关闭 7 个月前。 假
我有一个程序可以绘制一个简单的金字塔形状,我可以用箭头键旋转它,但我想把这个形状变成一架简单的飞机,而不是旋转我想让它继续用箭头键移动(飞行) .我怎样才能做到这一点? 这是我目前所拥有的: #inc
这是我的代码。我已经坚持了一段时间。我就是想不通。我遵循的指南要我在 Fighter 子类中使用 super.init(),但每次尝试时似乎都会给我一个错误。 class Spaceship {
为什么我们在 C++ 中需要这样的运算符,它在现代 C++ 编程中有何用处?任何可以应用此方法的真实代码示例都会有所帮助。 这个问题旨在了解现实世界中的实际应用,而无需阅读 Herb Sutter 的
我想知道 php 宇宙飞船运算符如何比较字符串、对象和数组。例如,下面的代码。 echo "Its Me at SO" "Its Me at SO"; 将返回 0,因为我知道所有字符都相同,计数相同
在 PHP 7 中,我们有一个新的运算符,宇宙飞船运算符 , 我发现它与 strcmp() 非常相似(如果不相同的话) . 它们之间有什么区别吗? 编辑:我问的是它们之间的区别,未提及 What i
我正在和一些人一起开发一个 3D 空间交易游戏,我被指派做的其中一件事是制作一个引导计算机“隧道”,让船通过,隧道由正方形组成用户飞到他们的目的地,随着用户离目的地越来越近,数量会增加。 只需要为船前
我是一名优秀的程序员,十分优秀!