r/futile • • May 21 '13

Some help

Hey im using this Code but it always and it always is false

    float xx = ((Input.mousePosition.x + offsetX) * touchScale);
    float yy = ((Input.mousePosition.y + offsetY) * touchScale);

    for (int f = 0; f < filas; f++)
    {
        //cada fila
        for (int c = 0; c < columnas; c++)
        {

            if (this.world.Rectangulo[c, f].Contains(new Vector2(xx, yy)))
            {
                Debug.Log("Inside");
            }
        }

the world.rectangulo is an bidimensional array, that Im using simulation a grid, of 32x32 each cell, cause Im using drag and drop, and I just want that if I drop an item in one cordinate the cordinate could have an status,

this is the method that create the grid

that its inside the World class

private void CreateGrid() { int columnas=23; int filas = 15;

        int xmin = -400; //my resolution is 800 weigth it means -400 one side and 400 other side
        int xmax;

        int ymin = 240;// my resolution heigh is 480 it means 240 one side, -240 other side
        int ymax; 


        for (int i = 0; i < filas; i++)
        {
            //each row
            for (int j = 0; j < columnas; j++)
            {
                xmax=xmin+32;
                ymax = ymin-32;

                //each column
                //i is the column
                //j is  the row
                //rectanculo = Rect in spanish
               
                 //here im giving the values of each verice of the sqare or rect

                Rectangulo[j,i].xMin = xmin;
                Rectangulo[ j,i].xMax = xmax;
                Rectangulo[j,i].yMin = ymin;
                Rectangulo[ j,i].yMax = ymax;

                xmin = xmax;

            }
            ymin = ymin - 32; // -32 means that it start from -400 x cordinate, and 280 y cordinate,  
            // -32 means that every columns the file will be -32 pixeles and it will start a new row                      //down
             xmin = -400;
            xmax = 0;
        }

    }

I dont know why it always is false, cause, I loop all the screen resolution on the rectangulo array and then search with the if statement inside a HandleSingleTouchEnded(FTouch touch) and its always false, Help me

0 Upvotes

1 comment sorted by

1

u/MattRix May 21 '13

Well basically my advice is to just log out the touch position, and log out the rectangle positions, and see which ones are wrong. This doesn't really seem to have anything to do with the actual Futile touch code as far as I can tell.