R0J0hound's Recent Forum Activity

  • Ah ok that makes sense.

    Basically you want to put objects around the edge of the object and want the objects to be angled in the direction of the edge.

    There isn't a way to access the collision polygon. A way to approximate it could be to create a ring of objects around the ground then move them toward the ground's center until they collide with the ground. At that point the object's will be shrink wrapped around the ground. You could then find the angle of the edge by using the angle expression between two adjacent points.

    There are probably other ways to detect the edge. One could be to position invisible rotated rectangles around the shape in the editor to define the edge. You could also use the paster object to draw a Sprite in a warped way around the shape.

    Unless you're drawing the ground at runtime it's probably better to position the objects in the editor. I believe Sqiddster did that in Airscape.

  • I don't understand the question. Can you make a diagram?

    Best I can tell you want to put tiles on top of an irregular shape? What would that look like?

    Also what do you mean by an object ends? Do you mean it gets destroyed?

  • You'll have to export such a project to see how big it is. The images and sounds of your game will take up most of the space. Layouts and instances of objects take up a lot less space.

    The number of layouts doesn't affect performance.

  • There is a system action to set the layout size, but it's probably easier to just set the layout to unbounded and not worry about the layout's size.

  • If you design the starting plain in the editor then it's just a matter of creating other terrain where the plain ends.

    Let's consider creating the terrain to the right. You'll need two global variables for the X and y of the end of the terrain. You can set these values manually. Next you'll need a global variable to keep track of a random number. Your events could then look like this if each terrain piece was an object. Note the "---" means the event is a sub event.

    Global number X=400

    Global number y=409

    Global number terrain=0

    Start of layout

    Repeat 10 times

    set terrain to int(random(3))

    --- terrain = 0

    --- > create forest at (X,y)

    --- > add 200 to X

    --- terrain = 1

    --- > create hills at (X,y)

    --- > add 300 to X

    --- terrain = 2

    --- > create grass at (X,y)

    --- > add 400 to X

    Start of layout

    create right_cliff at (X,y)

    This is also assuming the values added to X are the width of the objects and the hotspot of the objects are positioned to the left.

    Anything more deluxe can be done in a similar fashion. For instance the terrain could consist of multiple created objects or you could even set tiles on a tilemap is you so desire, just be sure the tilemap is wide enough.

  • The customMovement behavior doesn't really add much to be helpful for that. maybe the "stepping mode" where you can check for collisions in the in between positions with the "on step" trigger.

    Pushing out once colliding isn't the best here. It would be better check if the way is clear before moving.

    And actually I would go for doing the whole thing with events.

    I'd put everything I wanted to collide with in a family and call that solid then the simplest example would be this:

    [negated] sprite: overlaps solid at offset (1,0)

    sprite: set x to self.x+1

    You could then extend it with a speed instance variable to make the acceleration and finer motion:

    [negated] sprite: overlaps solid at offset (self.speed*dt,0)

    sprite: set x to self.x+self.speed*dt

    sprite: add 1500*dt to speed

    else

    sprite: set speed to 0

    When hitting a solid it will look to stop short sometimes and close the gap. This can be improved by using a loop to check each step in between. for that add another instance variable called "delta". Another benefit is this keeps the objects on pixel coordinates while staying framerate independent. This adds consistency to the collisions so they always stop the same distance away.

    every tick

    sprite: add 1500*dt to speed

    sprite: add self.speed*dt to delta

    repeat sprite.delta times

    ---[negated] sprite: overlaps solid at offset (1,0)

    --- > sprite: set x to self.x+1

    --- > sprite: subtract 1 from delta

    ---else

    --- > stop loop

    --- > sprite: set delta to 0

    --- > sprite: set speed to 0

    Now you could instead use the custom movement behavior instead by setting the stepping mode property and using the on step trigger. The only issue is "on step" is triggered after the object moves so you'll have to back it up or push out. That can go wrong if it pushes out into another object, which can easily happen with objects with floating point coordinates while being close to each other.

    EDIT:

    Here's an example:

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

    The events are generic for any angle and I shrank the collision polygon a bit.

    One more thing that could be done with this is simultaneous movement of the blocks. Right now their motion is handled on by one, but you also could let each move a pixel, then repeat for all of their deltas are below 1.

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

    Further tweaks would probably be some rounding in some spots to keep things with integer values, but I'm not sure if it's needed.

    EDIT2:

    had a typo in limiting the speed. used max when it should have been min.

  • It shouldn't swing if everything is centered around the fixed joint.

    Here's an example of one way to do it:

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

  • There will be no transparency issues, but zorder can be a bit tricky.

    If everything you want to paste is only one object type you can do this:

    for each sprite ordered by sprite.zindex ascending

    paste sprite

    For multiple different object pasted in the correct order here's a capx with a function that can do it.

    https://www.dropbox.com/s/3teztza6jcood ... .capx?dl=1

    /examples30/paster_pasteLayer_solution.capx

    You'll have two duplicate a few events in it for every object type you want to be able to paste, but hopefully it's straightforward to see which ones.

    Basically what it does is find the highest zindex out of all the objects on a layer, then loops over the zindexes and pastes the object with that zindex.

    EDIT:

    And just to be clear this doesn't consider the transparency of the layer.

  • You need to disable the collisions between the objects I think. The simplest way to do that is to make there collision group 1.

  • Yeah, I meant the one you can set from the property on the left.

    Here's a dual example for canvas and paster:

    /examples30/mirror_paster_canvas.capx

    https://www.dropbox.com/s/e19zxibiaehbb ... .capx?dl=1

    Paster doesn't have a paste layer action currently because making it work with C2's webgl is a mess right now. I can't really tweak it to work without major changes.

    Even if you have to loop over the instances and paste them individually you'll still get better performance with paster. With webgl on the canvas object has to copy itself to a webgl texture every frame it changes. That is the main performance hit you were getting from the first example. Using one canvas should help, but it's still inefficient.

  • Sure it is, just not in the editor from what I can tell. You can take a texture and draw one part of it to one quad and another part of it to another. 9patch is a good example of that. You can do that in the editor and at runtime.

    The only limit is you can't set the blend mode with js in the editor. At runtime you can do that no problem, just set the blend mode before each quad drawn.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use just one canvas object, or even better a paster object. The paster object is about the same as canvas, but is much faster with webgl on.

    Basically to do the reflection you set the origin of the object to be at the top, and position it where you want it in the editor.

    Then with events you'd do this every tick:

    1. clear the texture

    2. set the height to -self.height to flip it

    3. paste anything you want to reflect

    4. set the height to -self.height to flip it back

    The gradient could be done with another object on top, and the wave effect is simple with one of C2's shaders.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound