R0J0hound's Forum Posts

  • Juicy

    It sorts the order the sprites are drawn so the ones higher on the screen are behind the ones lower.

  • irina

    First you need to load that js library. You can do that by running this js at the start of the layout:

    "var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://antimatter15.com/ocrad.js/ocrad.js';
    script.onreadystatechange = script.onload = function(){console.log('occad.js loaded');};
    head.appendChild(script);"[/code:2pnob2x6]
    
    It can take time to load, so you shouldn't try using it right away.  You can tweak it so you're signaled when it's done loading but it makes things more complicated, so for now you can wait a second or so before trying to use it.
    
    The one function used in that link is OCRAD(c), where "c" is an html5 canvas.  The only readily available one would be the game canvas which can be gotten with document.getElementById('c2canvas').
    
    In my test I did this to get the result:
    
    time=1 seconds:
    --- set text to Browser.ExecJS("OCRAD(document.getElementById('c2canvas'))")
  • dahu

    One way is to paste an object that is using the destination out blend

  • You could just store the uid of one array in another. Then you'd pick the other array by uid before using it.

    Or taking the idea further you could use iid's instead. Which would still require you to pick the array before setting values, but you could then get values with:

    Array2(Array1.at(1,4,5)).at(4,6)

  • I made this a while ago:

    I'm unsure if it would be helpful, it comes across as fairly complicated.

    Basically what you could do first is place all your tiles down as sprites. Next put the tile sprite in a family and give them a boolean variable called "selected". The reason for a family is so two separate instances can be referenced.

    You then can expand the selection one unit in all directions with:

    Family1: boolean "selected" is true

    Sprite: is overlapping family1

    --- sprite: set selected to true

    Throw a repeat above that if you want it done multiple times:

    repeat 2 times

    Family1: boolean "selected" is true

    Sprite: is overlapping family1

    --- sprite: set selected to true

    The only issue now is diagonal tiles are also selected. To fix that make the tile's collision polygon with beveled corners or more octagon shaped.

  • ethanpil

    It already has this feature: Canvas.imageUrl which is the entire canvas. To paste a smaller area, first paste it to a smaller canvas object and save that.

  • Prominent

    I hadn't anticipated that case where a joint still affects a disabled object. I guess I may need to remove the object further from the sim, as right now it just is removed from the simulation space. To be able to disable joints would also need some some work, since it's not nearly as straightforward as disabling objects is now. This will have to wait until I get to re-reviewing the code.

    mattb

    Thanks for the bug report as always. I haven't touched the code for a bit so I need to re-familiarize myself with it. Well, that and I need to then rework a lot of it to address the requests and feature requests of the last few pages. I'll see if I can make some time this week perhaps.

  • Basically you'd make a sprite per pixel. You can access the pixels with the canvas object. In the example below I just had a separate frame per color. Then the melting effect is just a matter of giving a delay to the pixels before they will fall.

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

  • If you want to do scripting instead of events,the two options are making a plugin with the sdk or using the run javascript action of the browser object.

    Using the sdk is the encouraged method but you can't access other objects in the same way as events. The focus of this engine is the event system, so that is the easiest way to access everything in most cases.

    Using the "run javascript" action of the browser object doesn't really have access to anything else in the project. It is mainly used to use some outside library or something. There are ways to access other parts of the engine but it is kind of hacky and will not work if you export with minification.

    JavaScript is like the back end of the engine, so apart from the sdk it wasn't meant to be used in snippets in the editor.

    That said for a script like that you could do most of it with the "run javascript" action. Everything except the drawing.

    The pattern I use is to define functions with a "run javascript" action under a "start of layout" event:

    window.foo = function()
    {
       // do stuff
    };[/code:17urld6s]
    "window" is javascript's global object.  It's important to define it that way or you won't be able to call it again.
    So at that point you can call that function with a string like "foo()" anywhere else.
    
    The next issue is to get the results so you can use it.  The browser object also has an "evaluate javascrpt" expression that you can use to get a return value.  The only two types that C2 accepts are numbers and text, so you could return the array as text and use some events to parse it so you can use create objects to represent your map in the engine.  You could even return a json string that the array object can load, but it would take more code to format it right.
  • I don't have CC installed on right now so I can't open your cap.

    To make it go up first you just need to set the vy to negative when you spawn the bullet.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's an example:

    https://www.dropbox.com/s/eftq33ve74rul ... .capx?dl=0

    It's actually three parts. The first is to move the ball. The second is to move the ball backwards out of the walls. The third is to calculate the normal from the ball to the walls so we can calculate a bounce. It's an approximation that may or may not be good enough.

  • The teleportation is due to the method C2 resolves the collision. You can use the two ways from the custom movement behavior's push our actions.

    One is "push out nearest" which searches in a spiral like path around the object until a free spot is found. It works pretty well most of the time but in tight spaces like you have it can find a spot which isn't the nearest.

    Another is the object moves backward until it's no longer overlapping. That works well except after the bounce. The issue is the backward motion is in steps and after a bounce the backward step could be too much so instead of stepping back to the starting position it could pass it back into a solid so it effectively could tunnel out.

    The physics behavior is a simple way to have better collision resolution in that case. Or you can also do it all manually to have full control and in many cases have better results.

    I'll see if I can wip up an example. A simple idea that strikes my fancy currently would be to do the push backward idea except keep it from pushing back further than the old position.

  • For the math, give the sprite two variables:

    velocityX and velocityY

    Then make this event:

    Always:

    --- sprite: add 100*timedelta to veloctyY

    --- sprite: set x to sprite.x+sprite('velocityX')*timedelta

    --- sprite: set y to sprite.y+sprite('velocityY')*timedelta

    The 100 is the gravity which you can adjust.

  • akkthedev

    You can access the pixels, but that is the extent this plugin provides. Outside of that you'd have to find other means.