# Grab the image on top

**URL:** <https://forum.kirupa.com/t/grab-the-image-on-top/330763>\
**Category:** Uncategorized\
**Created:** [March 12, 2013, 4:47pm UTC](https://forum.kirupa.com/t/grab-the-image-on-top/330763 "2013-03-12T16:47:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bking20](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bking20](https://forum.kirupa.com/u/bking20)\
**Post date:** [March 12, 2013, 4:47pm UTC](https://forum.kirupa.com/t/grab-the-image-on-top/330763/1 "2013-03-12T16:47:52Z")

</div>

I’m making a game that involves grabbing coins and moving them to a location. At this point, I have an array of quarter images and I need for the hand cursor to ONLY grab the top image when two of the images get overlapped.

Here’s the part of the code in question:

```auto

function gameStart():void 
   {
    Mouse.hide();
    openHand.x = mouseX - (openHand.width / 2);
    openHand.y = mouseY - (openHand.height / 2);
    handClosed.x = mouseX - (handClosed.width / 2);
    handClosed.y = mouseY - (handClosed.height / 2);
    
    counter = 0;
    **do{
     if (quarter[counter].hitTestObject(handClosed) && mouseDown==true) { 
      quarter[counter].x = mouseX - (quarter[counter].width / 2);
      quarter[counter].y = mouseY - (quarter[counter].height / 2);
     }
     counter++;
    } while (counter < 5);
** }

```
