R0J0hound's Recent Forum Activity

  • You can also draw a distorted texture with the paster plugin:

    I've used it for 3d here:

  • You may try looking in this plugin here:

    In it there's an action to move the origin around and the collision polygon is updated. Maybe that could be a reference.

  • Saitama

    For me the error is "Cannot read property 'c2obj' of undefined".

    Looking at your event, when you create the joint you set "Object2 UID" to 2.

    The wire does have a uid of 2 but it doesn't have the chipmunk behavior. You can only create joints between objects with the chipmunk behavior.

    In my example I used -1 for "object2 uid". That means just connect to a fixed location on the layout. The wire in my example didn't have the physics behavior either, it was just for a visual.

  • All the instances of a sprite share the same animation images. The current frame of an instance just references which image of that sprite object is used. So when you load a image from a url it replaces the shared image.

    In other words say your sprite is named "sprite" and it has three animation frames.

    Sprite object:

    frame 1

    frame 2

    frame 3

    Next you have four instances, all which use frame 1.

    sprite instance 1 -> frame 1

    sprite instance 2 -> frame 1

    sprite instance 3 -> frame 1

    sprite instance 4 -> frame 1

    So now if you use the "load image from url" action the instance's image isn't replaced (instances only reference images), instead the "sprite" type's image is replaced.

    You can't add a frame on the fly with the sprite object. You could just set each instance to use a different frame, but yeah you do need to add them at edittime.

  • The problem is getting a good function name from all the actions and conditions, since they are mostly just sentences and there isn't any real consistency. I guess the function names from the runtime could be used, but I imagine some plugins could have some names completely different from the action/condition. Construct Classic allowed python scripting which allowed you to do this to an extent, but you couldn't do the same thing as with events.

    Beyond that point the idea of a typed scripting version of events was proposed before and one argument against it was needing to deal with the syntax and typos of such a language, which is a task in and of itself. Kind of a different beast to what C2 does already.

    You could unofficially do this already though, by generating event xml files. But it is a lot of work as I see it.

    It has the same issue as trying to convert a capx file to say c++ source code: It's simple on a very small scale, but to support everything, fix bugs and support changes as C2 updates it becomes a ridiculous task.

  • The slight lag you see when a sprite is positioned to the mouse is a pretty common thing encountered in games in general.

    What happens is the sprite is positioned and the next vsync update the sprite is drawn. In that time the mouse could continue moving. In practice this delay is typically about a frame, but it can be longer if double or triple buffering is used as I recall which basically render frames ahead of time to help with performance.

    One solution in C2 to have an image match the mouses position exactly is to use the "set cursor from sprite" action of the mouse object. Other software can do something similar.

    Stuff like a windows app often use a different rendering pattern that allow things to be synced with the mouse exactly. Namely things are only redrawn when an event happens like a mouse move/click etc instead of at a regular rate of 60fps. Even then it's only part of the screen that gets redrawn, instead of everything.

    Edit:

    Going back to C2 the reason objects lag behind other objects they're pinned to is the the order the the pin behavior is run.

    Say you have three objects A, B and C.

    A is pinned to B and B is pinned to C.

    Ok next you move C.

    That frame first A's pin behavior runs first, but since B hasn't moved A isn't moved.

    Next B's pin behavior is run and it's position is updated from C.

    The result is A will lag behind a frame before getting in the correct location.

    This is the problem with behaviors sometimes, and why events are better imo, because you can control when things are done exactly.

  • kingpirux

    What newt said. I was using the uids at runtime, where they never change. Setting up the hierarchy from the editor is a different issue, but still can be done with an instance variable to give each instance a unique value. Just be careful not to give two instances the same value.

  • Chipmunk2d doesn't really have kinematic bodies like box2d.

    Wouldn't setting the collision to none, giving the object a high mass, and canceling the gravity like below work?

    sprite: chipmunk: on pre step

    sprite: chipmunk: apply force rect(0,-self.chipmunk.gravity*self.chipmunk.mass)

    I realize it doesn't match box2d's defination exactly...

    [quote:23aut8md]A kinematic body moves under simulation according to its velocity. Kinematic bodies do not respond to forces. They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass, however, Box2D stores zero for the mass and the inverse mass. Kinematic bodies do not collide with other static or kinematic bodies.

    Namely, not responding to forces. You can set the mass to be infinite with events but there is a NaN issue with the library when doing that so a very high mass is better.

  • Here's an experiment with some ideas.

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

  • I don't have a multi-touch device but you could try this. Put it before the event that positions the handles. The only conflict you may run into is dragging a handle while doing this.

    global number touchWidth_new=0
    global number touchWidth_old=0
    global number touchHeight_new=0
    global number touchHeight_old=0
    
    touch: on touch 1 start
    

    set touchwidth_old to (touch.xat(1)-touch.xat(0))*cos(sprite.angle) + (touch.yat(1)-touch.yat(0))*sin(sprite.angle)

    set touchheight_old to (touch.xat(1)-touch.xat(0))*cos(sprite.angle+90) + (touch.yat(1)-touch.yat(0))*sin(sprite.angle+90)

    touch: has touch 1

    sprite: pick instance with uid picked

    set touchwidth_new to (touch.xat(1)-touch.xat(0))*cos(sprite.angle) + (touch.yat(1)-touch.yat(0))*sin(sprite.angle)

    set touchheight_new to (touch.xat(1)-touch.xat(0))*cos(sprite.angle+90) + (touch.yat(1)-touch.yat(0))*sin(sprite.angle+90)

    sprite: set width to self.width+touchwidth_new-touchwidth_old

    sprite: set height to self.height+touchheight_new-touchheight_old

    set touchwidth_old to touchwidth_new

    set touchheight_old to touchheight_new[/code:fjvyjdm3]

  • The collision point thing is mainly a recommendation, and mainly relates to C2's collision detection system. The physics behaviors use their own collision detection system if that's of any concern. Overall I'd just test it and see if it works fast enough for your liking. If not simplify your collision polygons.

    The other aspect you're testing with big backgrounds and one instance per Sprite will just use more video memory. You can leave it as is and if it works, great, but the memory requirements for your game will be higher which limits what systems can run it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You mean my example causes that error? Or in your capx?

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound