The full "card" images will be drawn onto a "board" image which is visible in the game, and a corresponding box of colour will be drawn on a hidden image, with a different colour per card. When I press or tap or swipe on the board, the game needs to know which card I'm interacting with, hence the hidden image with boxes of colour in place of cards. The boxes of colour may overlap in the same way the cards are overlapping in the game.
If the equivalent pixel I tap is green on the hidden image, then the game knows I've tapped a particular card, and likewise with red, blue, whatever colours I decide to use.
My question (or rather request) is a quick rundown of how I use GetPixelData to accomplish this or whether there's a better way of doing it. What kind of format does GetPixelData return? Could I reformat this into R, G, B values?
Thanks very much!
function GetPixels(image)
{
//Get the raw base64 encoded rgba string
var rawData = image.GetPixelData( "RawBase64" );
//Decode the base64 encoded string
var byteArray = atob( rawData );
//Convert the decoded byteArray into array of pixels objects
var pixels = [];
var byteIndex = 0;
while( byteIndex < byteArray.length )
{
var pixel = {};
pixel.r = byteArray.charCodeAt(byteIndex++);
pixel.g = byteArray.charCodeAt(byteIndex++);
pixel.b = byteArray.charCodeAt(byteIndex++);
pixel.a = byteArray.charCodeAt(byteIndex++);
pixels.push(pixel);
}
return pixels;
}Does anyone know?
Also a hint on how to convert ev.X and ev.Y (from img_OnTouchDown) to the same units would be greatly appreciated.