R0J0hound's Forum Posts

  • 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.

  • Try Construct 3

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

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

  • I think you need to detect which side is being collided with for it to work right.

    Maybe you could do something like this?

    Sprite on collided with tiledbg

    Sprite.y<tiledbg.top

    Or

    Sprite.y>tiledbg.bottom

    bounce vert

    Sprite.x<tiledbg.left

    Or

    Sprite.x>tiledbg.right

    bounce horz

    A more robust way could be to compare angles like

    Angle(tiledbg.x,tiledbg.y,Sprite.x,Sprite.y) is within 45 degrees or 0

    bounce horz

    Anyway just some ideas

  • Seems to be a general problem with destroying objects with this behavior. Not sure when I'll have time to really break it down and see what design flaw I used.

  • You can do this already.

    First select all the relevant events.

    Then right click on the selection and click "replace object".

    It will then let you pick the object to replace and what to replace it with.

    There are restrictions though. Like you can only replace sprites with sprites or tiledbg with tiledbg objects. And if any of the events access a variable or behavior, the object you replace it with needs it too.

  • I did a game like that a while back here:

    https://dl.dropboxusercontent.com/u/542 ... 9tile.capx

    It could be simpler but i was going for a dragging mechanic.

    korbaach

    I solved that by starting with it solved and then having it do 100 random moves or so.

    ajvar23

    You can greatly simplify your capx in a few ways:

    * use different animation frames instead of different sprite types.

    * only position detectors around the sprite you tap.

  • shinkan

    Well, with webgl on it uses the same drawing method that sprites use, and it is two triangles.

    Oh wait, if you're trying to do perspective it won't look right because there is no z.

    The picture here sums it up:

    https://en.wikipedia.org/wiki/Texture_m ... orrectness

    So basically the distortion only looks right if opposite sides of the quad are parallel. Something like a skew would work, but not if you do a trapezoid shape.

  • shinkan

    That's when webgl isn't used. The canvas workaround draws as two triangles and the anti-aliasing causes the seam.