R0J0hound's Forum Posts

  • The normal is just the angle perpendicular to the edge facing out. For instance the slope (rise/run or change in y divided by the change in x) or the right edge is 2/1 and the norm slope is 1/-2. The calculation of angle from slope is angle(0,0,run,rise). Another way is to guess the angles, test and re adjust

  • The event 11 trick was so the pinned connector sprite's positions would be updated before moving.

    The reason for this is the game flow is like the following and we have to wait for the next frame for pin to run again.

    behaviors -> event sheet -> draw -> repeat.

    Wait 0 or with a very low time can be ready by the end of the event sheet, so wait with a higher value or "wait signal" worked. Although I agree it's not a very clean solution.

    The clean solution would be to do pin in events so I can update the pinned objects whenever I need.

    https://dl.dropboxusercontent.com/u/542 ... zzle2.capx

    But sometimes it's easier to just make do with exiting behaviors.

  • Well, take for instance a box rotated 45 degrees. Then if you stretched it vertically relative to the screen you would get an elongated diamond. There isn't a way in C2 to stretch the box like that. Other than that the math is not bad.

  • codah

    The math for the angle was simpler than I thought, but I was messing around with it blind for a bit.

    https://dl.dropboxusercontent.com/u/542 ... uzzle.capx

  • My idea would be to first have a sprite pinned to the center of snap-able each edge center of each shape. Let's call them "edge".

    Then when a shape is dropped pick the closest other edge that's closest to each of the shapes edges. Of the two pairs of edges only keep the closest. A little tedious to make events for but that would give you the two edges that would need to snap together.

    The snapping could be done by moving the dropped shape by the offset of the edges and orienting them based on the normals of the edges.

    I'm attempting to come up with an elegant event setup, so stand by for a capx.

  • spacedoubt

    You can do what you described like this,at least for the first part that is.

    https://dl.dropboxusercontent.com/u/542 ... w_rot.capx

    The bounding box of a rotated triangle can be found by adding an image point at each corner of the triangle and then finding the min and max horizontally and vertically.

    And like you said you can make the bounding box only update after rotation. The only tricky part was positioning the bounding box while rotating, but there's a useful formula for that here:

    https://www.siggraph.org/education/mate ... 2drota.htm

    And while I was at it I added the ability to rotate around any point for little extra effort,

    The only aspect of that can't be done is resizing in relation to the screen, as that would introduce skewing, which C2 can't do. So you'd be limited to only resizing relative to the object.

    Edit:

    Here it is working with multiple objects. Shirt click to toggle selection.

    https://dl.dropboxusercontent.com/u/542 ... multi.capx

  • Chigabooga

    To do that you won't be able to use the particle object as the particles don't interact with anything. You'll have to use sprites with maybe the bullet behavior.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For something like this you'd have to install to a different location and use a diff program like winmerge to see exactly what changed in the files.

  • It doesn't work because of your second else. If you're over object 1 the first event works and sets the text, but then event 2 runs and since you're not over object 2 it sets the text to "".

    Do this instead.

    always

    --- set text to ""

    player is overlapping object1

    --- set text to "object1"

    player is overlapping object2

    --- set text to "object2"

  • A function is run as if it was instead placed where the function call was. Minus any picking. So it doesn't count as a toplevel event.

    "Wait 0" is a fix since it waits to run the following actions and sub events till the end of the event sheet where created objects are pickable as normal.

    As for what is happening consider

    start of layout

    ---- create sprite

    Before the event you can think of the state of the engine like this:

    sprites=[0,1,2] // A list of all the sprite instances

    picked=[] // A list of picked sprites

    new=[] // A list of new sprites

    Inside the event "picked" gets a list of all the sprite instances

    sprites=[0,1,2]

    picked=[0,1,2]

    new=[]

    The "create" action adds the the new object to "new" and picks only that.

    sprites=[0,1,2]

    picked=[3]

    new=[3]

    Then upon leaving the event the "new" list is moved to the "sprites" list:

    sprites=[0,1,2,3]

    picked=[]

    new=[]

    So the main point is the "new" list is only merged with the "sprites" list between toplevel events.

  • If you want to do it with events you can give the animations number names like (1,2,3,...). Or even better numbers in combination with a word like (run1,run2,run3...). Then you can use the set animation action with the expression "run"&n where n is an index.

    If you want to do it in a plugin with the javascript sdk then look here:

    https://www.scirra.com/manual/29/object-type

    If the object has animations you can use something like type.animations[0] to get the name at index i. You can glean more info about it by looking at the sprite object's source.

  • You could use one of these:

  • http://stackoverflow.com/questions/9403 ... javascript

    Add the browser object and use these expressions to convert over and back.

    Browser.ExecJS("'"& char & "'.charCodeAt(0)")

    Browser.ExecJS("String.fromCharCode("& ascii &")")

  • Instead of building the first text right away store the two numbers in variables and the operator in another variable. Then you can build the first text with number1&operator&number2. Then just add some conditions checking what the operator and set the second text depending on the operator.

    global number number1=0

    global number number2=0

    global text operator=""

    Start of layout

    --- set number1 to round(random(1,100))

    --- set number2 to round(random(1,100))

    --- set operator to choose("+","-","/","*")

    --- set Text1 to number1&operator&number2

    operator = "+"

    --- set text2 to number1+number2

    operator = "-"

    --- set text2 to number1-number2

    ... etc

  • Here's the reverse.

    x = iy-320+ix/2

    y = iy-320-ix/2