pixel-perfect

Collision detection for rotated bitmaps on Android

折月煮酒 提交于 2019-12-24 09:19:14
问题 I need pixel-perfect collision detection for my Android game. I've written some code to detect collision with "normal" bitmaps (not rotated); works fine. However, I don’t get it for rotated bitmaps. Unfortunately, Java doesn’t have a class for rotated rectangles, so I implemented one myself. It holds the position of the four corners in relation to the screen and describes the exact location/layer of its bitmap; called "itemSurface". My plan for solving the detection was to: Detect

canvas.drawText with pixel perfect text on a canvas

半腔热情 提交于 2019-12-23 05:36:09
问题 THIS IS NOT ABOUT AntiAlias, Please read the question before answering thank you. ADDING BOUNTY TO--> android convert text width (in pixels) to percent of screen width/height Quality info --> https://stackoverflow.com/a/1016941/1815624 I am getting inconsistent results when trying to draw text on a canvas. Please help, thank you. I want the text to consume the same amount of scaled space on all devices I do not care about ANTI_ALIAS and have added the paint.setFlags(Paint.ANTI_ALIAS_FLAG);

How to deal with line-height while coding a pixel perfect design

我们两清 提交于 2019-12-21 04:55:11
问题 Here is a screenshot of the example design I made up: There is a 10px space between the bottom of the letters and the red line. I'm trying to replicate this with the following code: font: normal 40px arial; border-bottom: 3px solid red; padding-bottom: 10px; Technically, this code should give me exactly what I want. But it doesn't. Here is a screenshot of it in action in Chrome: Because of the line height, there's extra space between the text and the border. Here's an inspected screenshot on

Pixel perfect collision?

戏子无情 提交于 2019-12-12 18:16:17
问题 Is it possible to do pixel perfect collision in a view based application ? I've been looking for example codes but with no luck... Also can you use colored bitmaps to represent collision for a certain color ? 回答1: You can. It looks like it's easiest if you use a CGImage though. You could create a 2D boolean array to read the pixel values to construct a hit grid (basically a 2x2 matrix) and then store that with your game object class. You would need direct access to the pixel data for the

How can I achieve pixel-perfect positioning and spacing of textual elements across browsers?

末鹿安然 提交于 2019-12-09 13:53:04
问题 Right now, we are trying to achieve consistent formatting of textarea elements, across Safari/Chrome/Firefox/IE on Mac and Windows. I believe this may be a rabbit hole, since any combination thereof could produce formatting in a slightly different way -- maybe one combination adds a bit of padding to a div here differently than the others, another one breaks multi-line text there differently than the others, and so on. Instead of using textarea (or div ) elements, can we achieve pixel-perfect

How to do pixel perfect collision on many sprites in cocos2d?

隐身守侯 提交于 2019-12-07 16:41:03
问题 in my app I have a player and many enemies (about 100+)..I don't want to use CGRects because it doesn't fits to the enemies. Is there any example how to do pixel perfect collision detection in cocos2d with many sprites? Some explaination would be great ;) Thank you very much! EDIT : I'm using CCSprite and .png files. the png has transparency but it should only detect a collision on non-transparency pixels. Edit: My enemies are round. 回答1: Circle-circle collision is the easiest.. And computing

How can I achieve pixel-perfect positioning and spacing of textual elements across browsers?

家住魔仙堡 提交于 2019-12-03 22:22:36
Right now, we are trying to achieve consistent formatting of textarea elements, across Safari/Chrome/Firefox/IE on Mac and Windows. I believe this may be a rabbit hole, since any combination thereof could produce formatting in a slightly different way -- maybe one combination adds a bit of padding to a div here differently than the others, another one breaks multi-line text there differently than the others, and so on. Instead of using textarea (or div ) elements, can we achieve pixel-perfect positioning using HTML5's canvas ? Or using the Raphael JavaScript library? Or maybe some other JS

Opengl pixel perfect 2D drawing

廉价感情. 提交于 2019-11-27 12:41:24
I'm working on a 2d engine. It already works quite good, but I keep getting pixel-errors. For example, my window is 960x540 pixels, I draw a line from (0, 0) to (959, 0). I would expect that every pixel on scan-line 0 will be set to a color, but no: the right-most pixel is not drawn. Same problem when I draw vertically to pixel 539. I really need to draw to (960, 0) or (0, 540) to have it drawn. As I was born in the pixel-era, I am convinced that this is not the correct result. When my screen was 320x200 pixels big, I could draw from 0 to 319 and from 0 to 199, and my screen would be full. Now

Opengl pixel perfect 2D drawing

强颜欢笑 提交于 2019-11-26 15:58:46
问题 I'm working on a 2d engine. It already works quite good, but I keep getting pixel-errors. For example, my window is 960x540 pixels, I draw a line from (0, 0) to (959, 0). I would expect that every pixel on scan-line 0 will be set to a color, but no: the right-most pixel is not drawn. Same problem when I draw vertically to pixel 539. I really need to draw to (960, 0) or (0, 540) to have it drawn. As I was born in the pixel-era, I am convinced that this is not the correct result. When my screen