R0J0hound's Forum Posts

  • Cool effects!

  • You can use the physics behavior or this behavior with ball sprites that have their elasticity set to 1. Also you'll need to set the gravity to zero.

    You could also use this for a more perfect collision response. If it's an issue that is.

  • R0J0hound, I replaced the sprite 2, which overlaps a tile, with a bullet. While bullet is colliding with a tile, the effect of overlapping does not appear. What was wrong?

    It looks fine here. Slow the bullet if you want to see it longer.

  • "this" is undefined in your code. Setting "self" to "this" doesn't change that in this case.

    Read the "Function context" for the reason why:

    https://developer.mozilla.org/en-US/doc ... ators/this

    "close" is clicked and the then it calls onUIDialogClose() which in turn try's to call this.runtime.trigger().

    But this is undefined since onUIDialogClose isn't called from an object.

    Use the mouse plugin as an example. It sets up the callbacks from the onCreate function. That way the callback can know what self is.

    instanceProto.onCreate = function()
    {
    	var self = this;
    	jQuery(document).mousemove(
    		function(info) {
    			self.onMouseMove(info);
    		}
    	);
    }
    
    instanceProto.onMouseMove(info)
    {
    	this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnAnyClick, this);
    }[/code:3inczl09]
  • Update 2.0:

    Download in first post.

    * Fixed: Joint tags were not working.

    * Added: "for each collision pair" condition. "on post collide" only triggers when an object first hits. This will loop through all the current contact pairs.

    Document tidbit:

    Joint tags can be any string when adding joints. When using it in joint expressions you can also use a number index.

    So do this to get the type of the first joint

    Sprite.Chipmunk.jointType(0)

    Or the second:

    Sprite.Chipmunk.jointType(1)

    Also you can give more than one joint the same tag name. Using it in a expression will give the last joint with that tag. This allows you to modify the joint that was just added.

    So if you added two pin joints, both with a tag of "". Then the following expression will get the impulse applied to the second joint.

    Sprite.Chipmunk.jointImpulse("")

    Also attached is an example using the new "for each collision pair" condition.

  • "on post collide" is only triggered when two objects first collide (useful for sound). I need to add another condition to loop over all the collision pairs so you can check at any time.

  • Prominent

    Here's a proof of concept in events to see how it would handle. The result is decent, but it becomes much more complex if we wanted to use tile collision polygons. It would also take a while to implement this in a good js way. So long term I may implement something into the behavior but not at the moment.

  • Update 1.9:

    Download in first post.

    * Fixed: If a shape or joint was destroyed more than once it would crash.

    * Fixed: Expressions would sometimes return undefined if there wasn't any value. Now 0 is returned.

    * Added: "set joint properties" action to change joint specific properties after the joint is added. Things like spring stiffness, pin distance, etc ... see note[1]

    * Added: A bunch of expressions to get those joint specific properties: see note[1]

    joint_PinDist(tag)

    joint_SlideMin(tag)

    joint_SlideMax(tag)

    joint_SpringRest(tag)

    joint_SpringStiff(tag)

    joint_SpringDamp(tag)

    joint_RotaryLimitMin(tag)

    joint_RotaryLimitMax(tag)

    joint_RatchetAngle(tag)

    joint_RatchetPhase(tag)

    joint_RatchetRatchet(tag)

    joint_GearPhase(tag)

    joint_GearRatio(tag)

    joint_MotorRate(tag)

    * Added: An expression to get the joint's type as text: jointType(tag)

    * Added: Expressions to get the points that a joint connects to the objects. Either the current object or the other one:

    jointAnchorX(tag)

    jointAnchorY(tag)

    jointOtherAnchorX(tag)

    jointOtherAnchorY(tag)

    Note [1]:

    If the action or expression used doesn't match the joint type then the action will do nothing and the expressions will return 0.

    Prominent

    Line segments might help with that but I currently have no plans to implement it.

    You could bevel the player's collision polygon a bit.

    -cheers

    Edit:

    Last minute fix. Re-download version 1.9.

    * Fixed: "Enable/Disable" and "Set immovable" actions would crash trying to remove a shape more than once.

  • Is the trigger function throwing the error? What does alert(this.runtime.trigger) give you?

    Edit: you can call the function but since the calling function isn't part of the instance object, "this" isn't an instance so it doesn't have this.runtime.

    If your object only ever has one instance you could add a global var that you set in your onCreate function to be "this", then you can use the var instead in your function.

  • You need one of the connected objects to get info about a joint. Makes sense since event sheets rely on picking, not to mention that's how chipmunk organizes the joints. I can add expressions to get the anchor point of the current object and the connected object. That would save needing to pick the other object.

  • That would be useful. Should the x and y returned be in layout coordinates or relative to the objects? I'm leaning towards "layout" but relative would be constant.

  • Here's a way to find all the tiles a box object is currently overlapping.

    If you want to check against a different collision shape and/or with a rotated shape then try the second one.

    It's also possible to use tiles with non-box collision polys but you just need to set the tile sprite accordingly.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Update 1.8:

    * Fixed: changing object shape then attaching a joint in the same frame was positioning incorrectly.

    -cheers

  • You could use something like the separating axis theorem with the collision polygons to find it if you need to.

  • I believe I found the issue. The shape isn't updated till the next frame. I just need to update it if needed when adding joints. It appears to be working, but I need to test a few more things. It should be ready tomorrow.