[SOLVED] How do I detect an object in a random area?

0 favourites
  • 11 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hi C2 community!

    I'm trying to find a way to detect an object within an random internal area comprised between a central object and a line composed by dashes generated by the touch of the player around this central object.

    I did this illustration below for you guys better understand the situation. If at least one of these objects stay in this random internal area, the player loses.

    I tried to make it through the Line of Sight behavior, calculating the area composed of each stroke object that makes up the broken touch and the central object, but didn't get success. <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    count_dash*distance(Central_Object.X, Central_Object.Y, Dash.X, Dash.Y)

    count_dash is a varible that count every dash spawned by the touch of the player.

    I thank you in advance your attention and collaboration. ^^

    SOLVED BY blackhornet! Link of CAPX example below:

    http://www.blackhornettechnologies.com/ ... tTest.capx

  • I would create a invisible object to be the area. It doesn't have any behavior or anything, it works just as a collision area. You could try that

  • You could look at the Canvas plugin. You can draw your user defined area, flood-fill, then use rbgaAt to detect overlap.

  • I would create a invisible object to be the area. It doesn't have any behavior or anything, it works just as a collision area. You could try that

    RayKi I need to create a random collision area within the dashed line. A static object isn't useful to accurately detect the internal area.

  • You could look at the Canvas plugin. You can draw your user defined area, flood-fill, then use rbgaAt to detect overlap.

    Thanks for the suggestion,

  • Master R0J0hound, I'm using the Canvas plugin (which is definitely the solution for this case), but I still cannot solve this problem.

    I'm trying to draw a line with the canvas whenthe player touch the screen, so the beginning of the line should amend it in order to involve an object. This "circle" must be filled by the canvas, creating a temporary object to be detected for collisions.

    I tried with Path, Move Pen, Draw Path and other with the Touch behavior, but I had no success.

    Sorry to bother you, but I'm just asking for help because I am not familiar with this great plugin.

    In advance thank you for your attention and collaboration.

  • Sorry, I was just working on it.

    This uses two canvas objects, one to draw, one to do the hit-test. I've assigned imagepoints at the corner of the test sprite. When one overlaps a filled area, it is "hit".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry, I was just working on it. http://www.blackhornettechnologies.com/ ... tTest.capx

    This uses two canvas objects, one to draw, one to do the hit-test. I've assigned imagepoints at the corner of the test sprite. When one overlaps a filled area, it is "hit".

    WOW! <img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked">

    Great job, blackhornet dude!

    I'm studing your CAPX now to implement it to my needs.

    Thanks for your help! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Hi blackhornet! Sorry to bother you again, but your detection system now detects only partially the object. (the purple box sprite)

    There is a way of detection occur only if the object is completely within the fill canvas color?

    Thanks one more time for your attention and collaboration. ^^

  • You could just change the detection to see if 'all' ImagePoints are overlapping, rather than 'any'.

  • You could just change the detection to see if 'all' ImagePoints are overlapping, rather than 'any'.

    Ok dude, I'll change this.

    Thanks again. ^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)