R0J0hound's Recent Forum Activity

  • sir LoLz

    I finally tried those solutions and you can't get the tilemap to draw tiles that are offscreen. Try instead to move the tilemap onscreen, paste it and move it offscreen. That should work.

    I haven't seen the second issue you describe and I can't reproduce it.

    frcol

    "Paste object" will draw the specified in place wherever it overlaps the paster object.

    See the attached example.

  • Finally saw this. Glad you got it working.

  • Updated to 2.1

    Download in first post.

    *Fix: Setting object to immovable after creating a joint in a "pre step" or "post collide" condition. Actually the fix should correct any errors claiming stuff is being added twice.

    *Fix: Setting immovable to No when it was immovable caused and error.

    *Fix: Angle would become nan if both connected bodies of a joint were immovable.

    *Fix: choosing 'Is disabled' condition would give 'For each collision pair' instead.

    *Fix: Error about removing/adding shape that isn't or already is in space.

    keepee

    Thanks, it was a typo on my part. I'm surprised that C2 didn't complain about that one.

    Prominent mattb

    Using the custom movement behavior isn't ideal for that sort of thing. Attached is a way to find the point on the edge of a shape. toggle between events 3 and 4.

    Event 3 uses the contact depth and normal to find the point on the edge, which works for other object's corners, but not the current object's corners. Not much can be done there as it's how the library works.

    Event 4 uses the query from point condition to find the closest point on the edge. This probably won't work the way you want with tilemaps though.

    Contact points are only accessible from under the "post collide" and "for each collision pair" conditions. So yeah you'd need to save the info to variables to use outside of that.

    A segment query from the object's center to the contact point may be one solution.

  • 1

    The cursor object only has the spring joint so only that gets destroyed. The pin joints are connected to the sprite object which isn't connected to the cursor object.

    2

    That event is to demonstrate joint breaking. With the event enabled pull one of the balls down. When you pull far enough the impulse on the joint will get too large and the joint will be destroyed so the ball will break free

  • Prominent

    The contact depth should be the distance from the edge, but I'll look into it. The point query condition will give a negative queryDist when the point is inside a shape.

    mattb

    That appears to be how the chipmunk library works. Those contacts flicker on and off when you look at it continually. I'll probably investigate further.

    I'll try to get those bugs fixed tomorrow. I'm also going to do some internal tweaks to better address future issues and hopefully prevent them.

    Documentation tidbit:

    The collision layers property is a list of 32 layers and whether an object is in one or not. I opted for 8 hexadecimal digits instead of 32 binary to shorten it.

    The default value: ffffffff means the object is in all the layers. Whereas 00000001 means the object is in that one layer.

    If you don't need all 32 layers and don't want to deal with hexadecimal numbers you can use 1 or 0 and have 8 layers.

    The objects can collide if any two digits are both 1. For example:

    Obj1 00000001

    Obj2 11111111

    They can collide.

    Obj1 00000001

    Obj2 11111110

    They won't collide.

    Obj1 11110000

    Obj2 00001111

    Obj3 11111111

    Obj1 won't collide with obj2 but both can collide with obj3

    Another way you can think of it is as a set of rules of what is allowed to collide with what.

    Player collides with wall, enemy and enemy bullets but not player bullets

    Wall collides with everything

    Player bullet collides with enemy and walls

    Enemy bullet collides with player and wall

    Enemy collides with wall, enemy and player bullet.

    Then you assign a layer to each

    Wall, player, enemy, player bullet, enemy bullet

    And with the rules set the layers accordingly:

    Wall 11111

    Player 11101

    Enemy 11110

    Player bullet 10110

    Enemy bullet 11001

    Another idea would be to have a seperate background layer with something moving and you don't want the player colliding with it. So for that the player's collision layer could something like 0001 and the background 0010.

  • Prominent thanks for the report. I'll be looking into it.

    spongehammer

    You can already get the impulse applied to a joint so yes you can make something like that.

    kmsravindra

    #1 Physics libraries are only a approximation, so energy isn't always conserved. You can increase the "global settings"->iterations to make it more accurate. You can also make the fixed timestep smaller to make collisions more accurate as well.

    #2 Toggling immovable isn't the best way to drag objects around. The switch discards any contact points and isn't very physically correct. A better way is to attach a joint to an object that is moved directly. See bottom of post.

    #3 If it causes a js error then it's a bug. I'll look into it.

    spongehammer

    It's correct, elasticity in physics is how a collision reacts, not how rubbery it is. An elasticity of 1 should mean that no energy is lost in a collision, which is pretty much how ball bearings act when they collide.

    Attached is a physics way to drag objects around. When you click on an object you create a joint to a no collision, immovable sprite that is moved around by the mouse. Then when the mouse is released the joint is removed.

    Also the joints in the capx are set to break if you're too rough.

  • Best I can tell it has to do with the "extend-box" property in the effect's xml file. When it's 0 the texture space (0.0 to 1.0) is from the left of the sprite to the right. But when it's non zero 0.0 is the left of the screen and 1.0 is the right. Also the following effects will inherit the same texture space.

    Here are all the variables that C2 sets for effects to use:

    pixelWidth
    pixelHeight
    vec2 destStart
    vec2 destEnd
    layerScale
    layerAngle
    vec2 viewOrigin
    vec2 scrollPos[/code:1mk58yqb]
    
    I think destStart and destEnd are the topleft and bottomright texture coordinates or something like that. Could be of use.
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "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.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound