Canvas's and Pixels

Problems with Canvas, OpenGL, etc...

Canvas's and Pixels

Postby multiplydivide » Sun May 30, 2010 12:35 am

I am developing a game which allows the user to create there own level. I have completed the part which allows the user to create the map but I was planning on doing the collision detection by pixel color. is there a way to retrieve the color of a pixel from a canvas?
multiplydivide
Developer
Developer
 
Posts: 34
Joined: Wed Apr 28, 2010 2:09 am

Top

Re: Canvas's and Pixels

Postby impi » Sun May 30, 2010 12:51 am

Well, you can do this with bitmap.getPixel();

You get an integer which is an color. with the Color class from android you can resolve the colorchannels and convert to hsv and so on...

You must use the bitmap of your map, or the specific tiles that are used for your map.
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Re: Canvas's and Pixels

Postby multiplydivide » Sun May 30, 2010 1:07 am

the map is stored as a two dimentional array list filled with points... lines are drawn in an on draw connecting the points so I have no bitmap... actually I think I just solved my own problem while typing this.... the map they draw is movable by a hand tool... I can get the relative posistion of the lines drawn from a fixed starting point, I am sure this does not make much sense as you dont see the code.... Man I love when solutions just pop into your head.....!!
multiplydivide
Developer
Developer
 
Posts: 34
Joined: Wed Apr 28, 2010 2:09 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests