- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个非常基本的图 block 系统,在其中我希望能够获取鼠标悬停在其上的当前图 block ,这对于创建的第一个图 block 非常有用,但除此之外我什么也没看。
这是设置和绘制图 block 的代码以及“当前悬停”文本。
private static final int TILE_WIDTH = 64;
private static final int TILE_HEIGHT = 64;
private static Tile[][] gridTiles = new Tile[(int)Math.ceil(Gdx.graphics.getHeight() / TILE_HEIGHT)][(int)Math.ceil(Gdx.graphics.getWidth() / TILE_WIDTH)];
public CombatGrid() {} // Cannot instantiate this class
static {
// Rows
for(int r = 0; r < gridTiles.length; r++) {
// Columns
for(int c = 0; c < gridTiles[0].length; c++) {
gridTiles[r][c] = new Tile((c * TILE_WIDTH), (r * TILE_HEIGHT), TILE_WIDTH, TILE_HEIGHT);
System.out.println("New tile("+r+","+c+") was created at: x: " + (c * TILE_WIDTH) + " y: " + (r * TILE_HEIGHT));
}
}
}
public static void draw(Batch batch) {
for(int r = 0; r < gridTiles.length; r++) {
for(int c = 0; c < gridTiles[0].length; c++) {
gridTiles[r][c].draw(batch);
if(gridTiles[r][c].hovering(Gdx.input.getX(), Gdx.input.getY())) {
Assets.defaultFont.draw(batch, "Current hover index("+r+","+c+")", Client.TOP_LEFT_X + 10, Client.TOP_LEFT_Y - 30);
}
}
}
}
文本仅在我越过 Tile[0][0] 时显示
这是 Tile 类的悬停方法
public boolean hovering(float x, float y) {
if((x > this.x) && (x < this.width)) {
if((y > this.y) && (y < this.height)) {
return true;
}
}
return false;
}
我传递给悬停的鼠标输入也是正确的,当我移出 0,0 block 边界时,它不再绘制。
另外,我正在调试我的鼠标位置
Assets.defaultFont.draw(batch, "Curret mouse X: " + Gdx.input.getX() + " Y: " + Gdx.input.getY(), Client.TOP_LEFT_X + 10, Client.TOP_LEFT_Y - 10);
它表明我设置的数学是正确的,或者至少应该是正确的,除非我错过了一些东西
现在,我知道所有图 block 都已被放大并正确放置,因为静态初始化程序中的调试语句
显示:
New tile(0,0) was created at: x: 0 y: 0
New tile(0,1) was created at: x: 64 y: 0
New tile(0,2) was created at: x: 128 y: 0
New tile(0,3) was created at: x: 192 y: 0
New tile(0,4) was created at: x: 256 y: 0
New tile(0,5) was created at: x: 320 y: 0
New tile(0,6) was created at: x: 384 y: 0
New tile(0,7) was created at: x: 448 y: 0
New tile(0,8) was created at: x: 512 y: 0
New tile(0,9) was created at: x: 576 y: 0
New tile(0,10) was created at: x: 640 y: 0
New tile(0,11) was created at: x: 704 y: 0
New tile(0,12) was created at: x: 768 y: 0
New tile(0,13) was created at: x: 832 y: 0
New tile(0,14) was created at: x: 896 y: 0
New tile(0,15) was created at: x: 960 y: 0
New tile(0,16) was created at: x: 1024 y: 0
New tile(0,17) was created at: x: 1088 y: 0
New tile(1,0) was created at: x: 0 y: 64
New tile(1,1) was created at: x: 64 y: 64
New tile(1,2) was created at: x: 128 y: 64
New tile(1,3) was created at: x: 192 y: 64
New tile(1,4) was created at: x: 256 y: 64
New tile(1,5) was created at: x: 320 y: 64
New tile(1,6) was created at: x: 384 y: 64
New tile(1,7) was created at: x: 448 y: 64
New tile(1,8) was created at: x: 512 y: 64
New tile(1,9) was created at: x: 576 y: 64
New tile(1,10) was created at: x: 640 y: 64
New tile(1,11) was created at: x: 704 y: 64
New tile(1,12) was created at: x: 768 y: 64
New tile(1,13) was created at: x: 832 y: 64
New tile(1,14) was created at: x: 896 y: 64
New tile(1,15) was created at: x: 960 y: 64
New tile(1,16) was created at: x: 1024 y: 64
New tile(1,17) was created at: x: 1088 y: 64
New tile(2,0) was created at: x: 0 y: 128
New tile(2,1) was created at: x: 64 y: 128
New tile(2,2) was created at: x: 128 y: 128
New tile(2,3) was created at: x: 192 y: 128
New tile(2,4) was created at: x: 256 y: 128
New tile(2,5) was created at: x: 320 y: 128
New tile(2,6) was created at: x: 384 y: 128
New tile(2,7) was created at: x: 448 y: 128
New tile(2,8) was created at: x: 512 y: 128
New tile(2,9) was created at: x: 576 y: 128
New tile(2,10) was created at: x: 640 y: 128
New tile(2,11) was created at: x: 704 y: 128
New tile(2,12) was created at: x: 768 y: 128
New tile(2,13) was created at: x: 832 y: 128
New tile(2,14) was created at: x: 896 y: 128
New tile(2,15) was created at: x: 960 y: 128
New tile(2,16) was created at: x: 1024 y: 128
New tile(2,17) was created at: x: 1088 y: 128
New tile(3,0) was created at: x: 0 y: 192
New tile(3,1) was created at: x: 64 y: 192
New tile(3,2) was created at: x: 128 y: 192
New tile(3,3) was created at: x: 192 y: 192
New tile(3,4) was created at: x: 256 y: 192
New tile(3,5) was created at: x: 320 y: 192
New tile(3,6) was created at: x: 384 y: 192
New tile(3,7) was created at: x: 448 y: 192
New tile(3,8) was created at: x: 512 y: 192
New tile(3,9) was created at: x: 576 y: 192
New tile(3,10) was created at: x: 640 y: 192
New tile(3,11) was created at: x: 704 y: 192
New tile(3,12) was created at: x: 768 y: 192
New tile(3,13) was created at: x: 832 y: 192
New tile(3,14) was created at: x: 896 y: 192
New tile(3,15) was created at: x: 960 y: 192
New tile(3,16) was created at: x: 1024 y: 192
New tile(3,17) was created at: x: 1088 y: 192
New tile(4,0) was created at: x: 0 y: 256
New tile(4,1) was created at: x: 64 y: 256
New tile(4,2) was created at: x: 128 y: 256
New tile(4,3) was created at: x: 192 y: 256
New tile(4,4) was created at: x: 256 y: 256
New tile(4,5) was created at: x: 320 y: 256
New tile(4,6) was created at: x: 384 y: 256
New tile(4,7) was created at: x: 448 y: 256
New tile(4,8) was created at: x: 512 y: 256
New tile(4,9) was created at: x: 576 y: 256
New tile(4,10) was created at: x: 640 y: 256
New tile(4,11) was created at: x: 704 y: 256
New tile(4,12) was created at: x: 768 y: 256
New tile(4,13) was created at: x: 832 y: 256
New tile(4,14) was created at: x: 896 y: 256
New tile(4,15) was created at: x: 960 y: 256
New tile(4,16) was created at: x: 1024 y: 256
New tile(4,17) was created at: x: 1088 y: 256
New tile(5,0) was created at: x: 0 y: 320
New tile(5,1) was created at: x: 64 y: 320
New tile(5,2) was created at: x: 128 y: 320
New tile(5,3) was created at: x: 192 y: 320
New tile(5,4) was created at: x: 256 y: 320
New tile(5,5) was created at: x: 320 y: 320
New tile(5,6) was created at: x: 384 y: 320
New tile(5,7) was created at: x: 448 y: 320
New tile(5,8) was created at: x: 512 y: 320
New tile(5,9) was created at: x: 576 y: 320
New tile(5,10) was created at: x: 640 y: 320
New tile(5,11) was created at: x: 704 y: 320
New tile(5,12) was created at: x: 768 y: 320
New tile(5,13) was created at: x: 832 y: 320
New tile(5,14) was created at: x: 896 y: 320
New tile(5,15) was created at: x: 960 y: 320
New tile(5,16) was created at: x: 1024 y: 320
New tile(5,17) was created at: x: 1088 y: 320
New tile(6,0) was created at: x: 0 y: 384
New tile(6,1) was created at: x: 64 y: 384
New tile(6,2) was created at: x: 128 y: 384
New tile(6,3) was created at: x: 192 y: 384
New tile(6,4) was created at: x: 256 y: 384
New tile(6,5) was created at: x: 320 y: 384
New tile(6,6) was created at: x: 384 y: 384
New tile(6,7) was created at: x: 448 y: 384
New tile(6,8) was created at: x: 512 y: 384
New tile(6,9) was created at: x: 576 y: 384
New tile(6,10) was created at: x: 640 y: 384
New tile(6,11) was created at: x: 704 y: 384
New tile(6,12) was created at: x: 768 y: 384
New tile(6,13) was created at: x: 832 y: 384
New tile(6,14) was created at: x: 896 y: 384
New tile(6,15) was created at: x: 960 y: 384
New tile(6,16) was created at: x: 1024 y: 384
New tile(6,17) was created at: x: 1088 y: 384
New tile(7,0) was created at: x: 0 y: 448
New tile(7,1) was created at: x: 64 y: 448
New tile(7,2) was created at: x: 128 y: 448
New tile(7,3) was created at: x: 192 y: 448
New tile(7,4) was created at: x: 256 y: 448
New tile(7,5) was created at: x: 320 y: 448
New tile(7,6) was created at: x: 384 y: 448
New tile(7,7) was created at: x: 448 y: 448
New tile(7,8) was created at: x: 512 y: 448
New tile(7,9) was created at: x: 576 y: 448
New tile(7,10) was created at: x: 640 y: 448
New tile(7,11) was created at: x: 704 y: 448
New tile(7,12) was created at: x: 768 y: 448
New tile(7,13) was created at: x: 832 y: 448
New tile(7,14) was created at: x: 896 y: 448
New tile(7,15) was created at: x: 960 y: 448
New tile(7,16) was created at: x: 1024 y: 448
New tile(7,17) was created at: x: 1088 y: 448
New tile(8,0) was created at: x: 0 y: 512
New tile(8,1) was created at: x: 64 y: 512
New tile(8,2) was created at: x: 128 y: 512
New tile(8,3) was created at: x: 192 y: 512
New tile(8,4) was created at: x: 256 y: 512
New tile(8,5) was created at: x: 320 y: 512
New tile(8,6) was created at: x: 384 y: 512
New tile(8,7) was created at: x: 448 y: 512
New tile(8,8) was created at: x: 512 y: 512
New tile(8,9) was created at: x: 576 y: 512
New tile(8,10) was created at: x: 640 y: 512
New tile(8,11) was created at: x: 704 y: 512
New tile(8,12) was created at: x: 768 y: 512
New tile(8,13) was created at: x: 832 y: 512
New tile(8,14) was created at: x: 896 y: 512
New tile(8,15) was created at: x: 960 y: 512
New tile(8,16) was created at: x: 1024 y: 512
New tile(8,17) was created at: x: 1088 y: 512
New tile(9,0) was created at: x: 0 y: 576
New tile(9,1) was created at: x: 64 y: 576
New tile(9,2) was created at: x: 128 y: 576
New tile(9,3) was created at: x: 192 y: 576
New tile(9,4) was created at: x: 256 y: 576
New tile(9,5) was created at: x: 320 y: 576
New tile(9,6) was created at: x: 384 y: 576
New tile(9,7) was created at: x: 448 y: 576
New tile(9,8) was created at: x: 512 y: 576
New tile(9,9) was created at: x: 576 y: 576
New tile(9,10) was created at: x: 640 y: 576
New tile(9,11) was created at: x: 704 y: 576
New tile(9,12) was created at: x: 768 y: 576
New tile(9,13) was created at: x: 832 y: 576
New tile(9,14) was created at: x: 896 y: 576
New tile(9,15) was created at: x: 960 y: 576
New tile(9,16) was created at: x: 1024 y: 576
New tile(9,17) was created at: x: 1088 y: 576
New tile(10,0) was created at: x: 0 y: 640
New tile(10,1) was created at: x: 64 y: 640
New tile(10,2) was created at: x: 128 y: 640
New tile(10,3) was created at: x: 192 y: 640
New tile(10,4) was created at: x: 256 y: 640
New tile(10,5) was created at: x: 320 y: 640
New tile(10,6) was created at: x: 384 y: 640
New tile(10,7) was created at: x: 448 y: 640
New tile(10,8) was created at: x: 512 y: 640
New tile(10,9) was created at: x: 576 y: 640
New tile(10,10) was created at: x: 640 y: 640
New tile(10,11) was created at: x: 704 y: 640
New tile(10,12) was created at: x: 768 y: 640
New tile(10,13) was created at: x: 832 y: 640
New tile(10,14) was created at: x: 896 y: 640
New tile(10,15) was created at: x: 960 y: 640
New tile(10,16) was created at: x: 1024 y: 640
New tile(10,17) was created at: x: 1088 y: 640
New tile(11,0) was created at: x: 0 y: 704
New tile(11,1) was created at: x: 64 y: 704
New tile(11,2) was created at: x: 128 y: 704
New tile(11,3) was created at: x: 192 y: 704
New tile(11,4) was created at: x: 256 y: 704
New tile(11,5) was created at: x: 320 y: 704
New tile(11,6) was created at: x: 384 y: 704
New tile(11,7) was created at: x: 448 y: 704
New tile(11,8) was created at: x: 512 y: 704
New tile(11,9) was created at: x: 576 y: 704
New tile(11,10) was created at: x: 640 y: 704
New tile(11,11) was created at: x: 704 y: 704
New tile(11,12) was created at: x: 768 y: 704
New tile(11,13) was created at: x: 832 y: 704
New tile(11,14) was created at: x: 896 y: 704
New tile(11,15) was created at: x: 960 y: 704
New tile(11,16) was created at: x: 1024 y: 704
New tile(11,17) was created at: x: 1088 y: 704
最佳答案
试试这个;
public boolean hovering(float x, float y) {
if((x > this.x) && (x < this.x + this.width)) {
if((y > this.y) && (y < this.y + this.height)) {
return true;
}
}
return false;
}
关于java - 循环遍历tiles,只有get才能获取第一个tile的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27350072/
这是引用 Google Tile Map 或 Bing Maps。是否可以在不使用任何类型的内部计算指定缩放级别(或 LevelOfDetails)的情况下获得 Tile Count、Tile X、T
我有一个 Tiles 模板,其中每个页面都提供一个标题,一些要添加到 中的内容,要放入一些混凝土的东西 ,以及附加到 的内容在一切之后。 大部分内容都非常小,因为页面是用 JS 呈现的。 我怎样才
我正在使用 Apache Tiles 2.1 开展一个项目。 我遇到了一个问题,即使用列表属性扩展模板会创建这些列表项的重复项...每个继承级别都有一组重复项。 作为示例,以下是基本定义及其将生成的页
我在 HTML 的背景层中有一个重复的水平图案。我可以使用 1 像素宽的图像或它的倍数(10、20、50...)来实现。 问题是: 哪个更好? 使用薄(小文件大小)图像并使其重复很多 使用更大的图片,
我们正在使用 Apache Tiles 3.0。 在我们的 Apache Tiles-Def 文件中,我们偶尔会遇到此 DTD 引用的问题,这可能是因为该站点不可靠。偶尔会出现“Reading Def
我在我的网络应用程序中使用 Tiles。我在瓷砖中使用了标准布局 (standard.jsp)。在 standard.jsp 之上有很多包含,涉及标签库等。 让我们做一个简化的例子。 标准.jsp:
我正在制作一个基于 2d tile 的游戏,我试图通过对 tile 结构中的值使用位字段和字节来保持我的 tile 结构小: struct Tile { // 3 bytes (24 bits
我已经在 Tiled 中制作了一张 map ,并且已经生成了一个 JSON。每当我尝试在 Chrome 中加载 map 时,它根本无法加载。当我去检查网站时,有类似警告: 在来自 Tiled 的 Js
我使用 struts 2.3.16 和 tiles 2.0.6。 具有空属性(以及其他属性)的图 block 定义: 一些其他定义扩展了它,他们可以选择填入值: 或者也留空。 我试图通过使用 st
我想在Struts2框架中使用tile。作为用于显示图 block 内容的标签,tiles:insert 和tiles:get 之间的基本区别是什么? 最佳答案 is equivalent to
我正在从 Strut1 + Tiles 项目迁移到 SpringMVC 和 Apache Tiles 3。我对Struts1+Tiles只了解一点点,它太旧了,我陷入了Struts-tiles中的Co
我正在使用Tiles,Spring和Hibernate创建一个应用程序。 在运行时,它显示以下错误: Can not find the tag library descriptor for "http
目前我在计划任务的帮助下实现了我的翻转图块,因此类似方法的一个问题是翻转图块将在时间间隔内翻转相同的图像。所以我想要实现的是我需要像循环瓷砖一样翻转我的图像。即一个接一个的方式。这里要注意的一件事是我
我正在使用 v0.6.2 和 Cocos2D v0.99.5,现在我真的非常需要为我的一些图 block 制作动画。我读了part of a wiki关于如何为图 block 制作动画,但它似乎与 M
我有一个图 block ,其中列出了提供给它的对象中的文章。此图 block 是大多数页面的一部分,但不是全部页面。有没有什么方法可以自动仅向需要它的页面提供对象(包含特定图 block )?现在我只
我正在寻找一种解决方案,以根据游戏 block 的类型对我的游戏 block 进行分组。瓷砖存储在二维数组中,类型为空和水,分组的瓷砖将存储在组类中。 所以如果我有二维数组: 0, 0, 0, 0,
我在今天的 maven 构建过程中遇到以下错误。 Unable to resolve artifact: Unable to get dependency information: Unable to
我正在尝试让 Apache Tiles' put-list-attribute 与 Thymeleaf 一起工作。 这是我尝试过的: 来自 Tiles 配置: 来自 thymlea
我在 UI 的 mat-grid-list 中动态显示 mat-grid-tile,其数量和数据随着后端值的变化而变化。它们是动态生成的。单击任何 mat-grid-tile 都会调用一个函数并将数据
我制作了一个 Tiled 游戏。现在,我正在通过增加场景中的节点数量来对手机的功能进行压力测试。有基于物理的东西,AI 运动,日夜系统,粒子在这里和那里突然出现以及我的场景的引擎盖下发生的许多其他事情
我是一名优秀的程序员,十分优秀!