Announcement

Collapse
No announcement yet.

img_touched question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • img_touched question

    Kind of confused as to why this is not working correctly. Trying to get a basic button working with 2 images I have. I have an up and down state image that I want to be up normally, down during press, up upon release. This works fine when I get the x,y coords myself and check against where the image is located. The problem arises when I attempted to use the img_Touched function. I was modifying TestImageControl and just trying to get it to work with one button for the moment.
    Code:
    if(state == TOUCH_PRESS) // if there's a press
    n := img_Touched(j, ALL); // see if any images were touched
    if (n == 0)
    img_Show(j, 1);
    endif
    endif

    if(state == TOUCH_RELEASE) // if there's a release;
    if (n == 0)
    img_Show(j, 0);
    endif
    n := -1;
    endif

    if(state == TOUCH_MOVING) // if there's movement
    endif
    The actual action works fine...the problem is that upon release the new up image is brightened considerably. What is causing this? I want the original image to be displayed normally again. I'm thinking I am just missing something simple here. Thanks for any help.

  • #2


    There is an easier way to accomplish the same task, and reduce image space, creation and maintenance.

    Use the img_Lighten or img_Darken function to produce the down state on press.
    Then call img_Show on release, the image will be re-displayed in normal mode.
    I am using this with success.

    I also tried running your example but had to make several assumptions on how you first intialize the display of the button. So my findings were different. Attach your full code for review.

    If you read my other post on the img_Touched you may avoid some more frustration later. Running your scenario where two images are the same size and are located in the same position, the image with the lower index will be returned. In other words the code will not see a returned index of "1", only "0". Try putting in a print(n) statement in you code to catch it.

    Regards,
    Aaron

    Comment

    Working...
    X