English 中文(简体)
简言之:建立一个无扭曲的平方网
原标题:Android: Creating a grid of squares that scales without distortion

I m an absolute beginner at Android programming, so please bear with me :) For my simple game, I m drawing a 20 x 10 grid consisting of squares at the beginning. Within the game, I would need to draw a sprite right at the center of some of the squares. (analogous to a Checkers grid, with a chip at the center of each square). I want this game to work across various screen sizes and densities. My approach has been to get the canvas width and height at the beginning of the game, calculate the side of the squares and then draw the grid out and save that as a bitmap, and then use that bitmap in the game. That way my grid would scale perfectly across screens.

(1) 是否有更好的办法? 曼 谷 我用电网的形象来替代地图吗? 我担心的是,当图像被提升到不同的屏幕上时,广场可能会被歪曲。 除此以外,很难计算每个面积面积面积的面积(放置间谍)。

2) 在屏幕上的某些地方,我还需要展示标题、分数、级别等。 是否最好将空间留给轨道图上,然后在轨道图上写记分,还是用水面电线和我写记分、等级等的另一种观点来绘制布局?

感谢!

最佳回答

使用9Patch .png图像,首先制作一种代表一个广场的形象,或形成一种代表你选择的20x10网的图像。 这样,它就看上去了一种 m(中型 do)的屏幕。

然后,你将需要为你打算支持的其他屏幕缺陷制作预先制作的图像。 焊皮的尺寸为原样的0.75, h皮为原样的1.5x,Xhdpi为原样的2x。

然后,你将图像列入贵项目的相关可提取资源目录,例如/res/drawable-mdpi和/res/drawable-hdpi等。

每一密度(例如,平方)的图像完全相同。 png or grid.png. 只要这些可提取的目录含有同一名称的图像,那么安乐公司就将找到适当密度和使用该名称。

它是一个长期的文件,但你确实需要阅读......。

rel=“nofollow> • 支持多种筛查

......特别是替代可提款的部分。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签