Overlapping at offset?

0 favourites
  • 9 posts
  • I'm having trouble with overlapping at offset. I want the big greenish square in the middle to read the angle of what ever smaller square it's overlapping at the yellow points but not able to at all. How would I go about achieving this?

  • Not sure I understand. You can define an image point (for the yellow dot) on small sprites and do something like this:

    SmallSprite is overlapping BigSprite
    For each SmallSprite
    .. use the following expression to get the angle from the center of big sprite to the yellow dot of the small sprite:
     angle(BigSprite.x, BigSprite.y, SmallSprite.ImagePointX(1), SmallSprite.ImagePointY(1))
  • I solved that problem. Now, i'm facing another problem. I'm trying to compare spr_Road.angle with value in intersection.anglesToRotate but the value outputted is all wrong.

    What I want is the the roads with same angle to be clubbed together into one.

    Here's the file File.

  • Again, I don't understand your question. Dealing with angles in Construct is tricky. In many cases you can't simply compare angle1 with angle2. I advise using "Is within angle", "Is clockwise", "Is counterclockwise" conditions, and expressions like anglediff()

    For example, if you need to know if spr_Road.angle and intersection.anglesToRotate are very close, you can do this:

    anglediff(spr_Road.angle, intersection.anglesToRotate)<5

  • This is what i'm trying to achieve. I'm storing the angle in a variable as text but i'm comparing it so that i don't restore the same angle twice but this the below code it's not working.

  • I'm not sure.. This is "On create" event, so initial AnglesToRotate values will always be the same for all newly created instanced, and will probably be an empty string.

    Try adding Browser Log to each event, for example:

    Browser Log "RedLight UID=" & Spr_RedLight.UID & " AnglesToRotate=" & Spr_RedLight.AnglesToRotate

    Run the game in debug mode, open browser console and try debugging.

  • I'm trying to check if the road touches the redlight at road's imagepoint 2 which isn't working for some reason.

    and then when it works I want to add all the road's angle to the redlight's variable "anglesToRotate" as sprite value, so that I can reference it later when I have to rotate the redlight. Which seems to be working, sorta.

    Can you please download the capx and see what the problem might be, i'm just stuck.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, I didn't notice you shared the capx in your earlier comment and made lots of wrong assumptions..

    Here is the fixed version:


  • This works perfectly... Thanks for the fix.. :)

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