R0J0hound's Forum Posts

  • I can have another go at it on another PC if I get a chance, but it's not simple to add. Previous attempts were requiring too much code to tweak.

    Overall C2's webgl renderer is made to work well with the screen and not arbitrary rectangles like this plugin does. Ideally I'd just call some functions from the renderer but as it turns out instead I needed to copy and heavily modify most of those functions. Pasting objects with effects is one such example and there are differences with my code that can make the pasted image not look the same. There's probably a simpler solution I haven't come up with yet but it'll probably be very hacky.

    That is probably one good reason why such a plugin like this would have benifited from being made officially. They could then be able to tweak their renderer to make such a plugin more streamlined.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can do what you want with a instance variable "parent" that you'd set the the parent's uid.

    The tediousness would be the picking other instances of the same type. The two way is either a family or storing values from another instance to variables. Functions would also be useful here to make the events more readable.

    For example if your object types look like this:

    sprite: ogre

    family: otherOgre

    variable: parent=-1

    Then your events could look like this:

    // this creates the hierarchy
    //  Ogre spawn 5 ogres, those ogres spawn 2 ogres
    
    Start of layout
    repeat 5 times
    for each ogre
    

    ogre: spawn otherOgre

    otherOgre: set parent to ogre.uid

    ---repeat 2 times

    ---> otherOgre: spawn ogre

    ---> ogre: set parent to otherOgre.uid

    on function "getParent"

    function: set return value to -2

    ---pick ogre by uid function.param(0)

    ---> function: set return value to ogre.parent

    global number dist=0

    global number ang=0

    global number X=100

    // ogre is the grandson, otherOgre here is the grandfather

    // i don't want the grandsons to be further than X distance from his grandfather

    for each ogre

    pick otherOgre by uid function.call("getParent", ogre.parent)

    set dist to distance(otherOgre.x, otherOgre.y, ogre.x, ogre.y)

    set ang to angle(otherOgre.x, otherOgre.y, ogre.x, ogre.y)

    --- dist > X

    ---> ogre: set position to otherOgre

    ---> ogre: move X pixels at angle ang

    //the grandfathers will move to his sons

    // here otherOgre is the father, ogre is the son

    for each ogre

    pick otherOgre by uid ogre.parent

    otherOgre: move 100*dt pixels at angle angle(otherOgre.x, otherOgre.y, ogre.x, ogre.y)

    //At the same time, the 5 grandfathers are not related so they will fight each other but will not harm their own family and will not damage grandsons of anybody, but the grandsons may hurt their own brothers but not their fathers.

    // If I understand that correctly you want

    // 1. gradparents to fight with each other

    // 2. grandchildren to fight with brothers

    // ogre and otherOgre are grandparents

    ogre: parent=-1

    otherOgre: parent=-1

    for each ogre

    for each otherOgre

    fight

    // ogre is a grandchild, and otherOgre is a brother

    ogre: pick by comparison function.call("getParent", ogre.parent) = -1

    for each ogre

    otherOgre: parent = ogre.parent

    for each otherOgre

    fight[/code:143vi5gb]

  • It's actually pickable at the next toplevel event too.

  • korbaach

    The difference is how colors are matched there. It checks if the colors are close, not exact.

  • rufson

    I couldn't get the "load texture from canvas" action to work reliably when I was implementing it. The issue is it seems to rely on some undefined behavior with webgl unfortunately, so it should probably be removed from the plugin.

    On another note webgl support for my graphics card is poor so even with webgl on it's not used when I preview. Support was better with older browsers oddly enough. As a result I have done nothing with webgl for a while now, so I probably won't have a fix for this.

  • You can't do that with z order. you could do it if you have the pink object on another layer with "force own texture", you'll need a forth object on that layer with the destination out blend over where you want to see through to the blue object.

  • Use a textbox instead, and set the font size with some css. You can even scroll the editbox by using some javascript with the browser object.

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

    The issue with the Text object is you're running into the browsers canvas size limit, and with webgl the texture size limit. You can circumvent it by using one text object per line if you still prefer to use them.

  • Couldn't you use the "on collision" condition?

  • Sounds like you want to save video memory. My idea above does nothing for that.

    Images are loaded/unloaded per layout:

    https://www.scirra.com/blog/112/remembe ... our-memory

    The most you could do is try do some juggling with animation frames, by just loading frames from a file as needed. Which would replace one image with another. I wouldn't go that route unless I was running out of video memory, and even then I would probably do something else since loading images from a file is slow.

  • 1. yes with the sdk:

    https://www.scirra.com/manual/15/sdk

    2. I think so. Depending on the export method there is a plugin for it to access exposed api features of the exporter. Not all but you could perhaps modify the plugin to access more features of the api.

    3. Again with the sdk. You can use the Browser object's execJs action to run snippets of js too, but it's unconnected with the rest of C2 and can break after exporting due to minifying.

  • It's not as simple as you'd assume and it actually wouldn't save on memory so much, unless you Incorporated loading from disk. It could save on cpu usage by reducing the amount of objects to process, but it will also take some performance to do the chunk loading. Also while it works ok for static terrain it becomes more complicated if you want stuff to be changeable. Moving objects are a big problem with this as well as they can move around and it may not be desirable to save them to a chunk.

    As a simple example with only horizontal scrolling and a screen size of 640x480 you could do the following. Say you want a chunk width of 640 pixels at any given time you could have 2 of them loaded, and for example we could define the center of the chunk to be it's location.

    We need to know two things: when to load a chunk and when to unload it. What can do is as the chunk gets too far left of the screen it gets unloaded and a chunk on the other side gets loaded.

    chunk.x<scrollx-640

    unload chunk

    set chunk x to self.x+640

    load chunk

    Also it can be done similarly if two far to the right.

    For the unloading I'd use instance variables on the objects that have the chunks id so you can pick them to destroy. For loading you'll need to store the object info in some kind of format. In the past i've used an array as json string to store the data. I'd store the values like this:

    array.at(x, 0) = type

    array.at(x,1) = x

    array.at(x,2) = y

    ...

    So to load it would loop over that array and create objects according to type. I've also done it so it's just a 1d array of dictionaries asJSON.

    The chunks themselves could be stored in an array of those json strings.

    I'd avoid all the above if I can. The goal should be to use less cpu. Just make the entire level in the editor. All the static objects are fine and you if you use a collision detection to pick the objects C2 has everything divided up into screen sized chunks so you can avoid processing far away stuff. Moving objects are the main issue to handle. A common thing is to disable or destroy them if they get to far from the screen.

  • Just to add onto fisholith's excellent post, here is an alternate equation that also gives a signed angle difference.

    angle_delta = angle(0,0,cos(b-a),sin(b-a))

  • dilk

    The simplest way to do it would be to fill a tilemap with a duplicate of your collision mask.

    To do this you'll need a tilemap with a 1x1 tilesize that covers the area of your collision mask image. It's only for collision detection so it can be invisible.

    Next you'll need a canvas object with the collision mask as its image.

    Then at the start of layout use two for loops to loop over every pixel. Use a system compare with canvas.alphaAt(X,y) to read the alpha of the pixel. If it's say >128 then set a tile on the tilemap at the same position.

    At the end of it the tilemap will be ready for collisions and all behaviors can interact with it. It can take a while to do, so as a speed up you could save the tilemap as json and use that in your actual game.

  • rufson

    Cool looking effect.

    Sorry, I don't use any mobile devices for testing and even so I have no idea why they work differently in some cases. This plugin is basically a thin wrapper to use c2's webgl renderer to draw to a texture. Which is something the renderer does with layers at times. So the performance is what it is, not much I can really tweak.

    Skewing would be annoying, maybe you could use only power of two sizes?

  • Why is 5mb too big? You can't split that file but you could do your own level file format and load that as needed with Ajax.