R0J0hound's Forum Posts

  • Yes. Look in the xml manual entry:

    https://www.scirra.com/manual/139/xml

    Specifically the links about xpath, you can reference anything to loop over.

    ex.

    XML For each node key "/test/question"

    --- Text set text to XML.StringValue("option")

  • If you have one sprite that is frame 1 already, you can make it spread in eight directions by putting the sprite in a family then making an event like this:

    every 5.0 second

    family1 animation frame=1

    sprite animation frame=0

    family1 is overlapping sprite

    --- sprite set animation frame to 1

    Of course that is a very general case. For your current setup you could do something simple like this to make the sprites turn red from the right to left with 5 seconds in between.

    Start of layout

    For each sprite ordered by sprite.x descending

    --- wait 5*(1+loopindex) seconds

    --- sprite set animation frame to 1

  • A while back I came up with a way of doing a game like Quilox, which is very similar to qix. It was slow and unfortunately the capx doesn't work the same with newer versions of C2 due to a breaking change.

    Anyway for such a game the idea of doing a flood fill from all the enemies works well to indicate the play area, and anything not flood filled can be safely erased to show what's underneath. The second hurdle is having a way to draw and cut up the play field. Ideally pixels would be used as thousands of 1x1 sprites will drag down performance. The canvas object could be used and there are per pixel collision detection capx' around the forums that will also prove useful. One caveat is I don't think it's flood fill action will work for this problem, so it may have to be done manually. Or if you don't mind it much coarser you could use a bunch of larger sprites. Just find a balance between performance and detail.

    For objects only moving on the unrevealed area the idea is basically this:

    . if object is on play field.

    . then move object

    . if object is now not on the play field

    . then undo the move and pick a new direction to move.

    . repeat

    Here's an unpolished example to pick apart using vanilla c2 events:

    https://dl.dropboxusercontent.com/u/5426011/examples19/qix_like.capx

  • newt

    It should be working, re-download it. I fixed it after MadFactory reported it in the second post.

  • Here is an example somewhat following vee41's idea of using a flood fill:

    https://dl.dropboxusercontent.com/u/5426011/examples19/wall_build.capx

    In a nutshell it marks every grid as EMPTY then marks all grids with walls as FILLED. After that an eight direction flood fill is done starting at the top left corner (0,0), and finally the grid array is looped over and any grid positions still EMPTY are enclosed and can be drawn blue.

    It has a lot of room for improvement but should give a basic overview of the concept.

  • As far as I can tell when creating an object at runtime the first instance you inserted at edit time is used to the object's created state. It can be a problem to find that instance unless you put it on an asset layout first. I usually just manually set the object state manually when creating at runtime though and completely disregard the edit time values.   It would be useful if there was a way at edit time to pick the initial object or even make a certain instance the reference for default values.

  • The sdk manual describes what they do here:

    https://www.scirra.com/manual/23/runtime-functions

    under "draw(ctx) and drawGL(glw)"

    And it's the runtime that calls them. For more detail: in preview.js the runtime calls the layout draw function in layout.js whenever a frame is to be drawn. From the layout draw function each layer draw function is called (same file) and from there each instance's draw function is called.

    You can't control when the plugin's draw functions are called but you don't have to draw anything when they are. It's quite doable to do as you mentioned to wait a time interval between draws by saving the current time and comparing against it every time the draw funtion is called. However it would only cause your object to flash one frame before the background and other objects would overdraw it after that until it flashes again.

    Here's how you could do it.

    1. add a variable to instanceProto.onCreate so you can save the current time.

    this.oldTime = 0;
    this.timeInterval = 1; //in seconds

    2. add this to the top of your draw and drawgl functions:

    var currentTime = this.runtime.kahanTime.sum;
    if (currentTime >= this.timeInterval + this.oldTime)
        this.oldTime = currentTime;
    else
        return;
    // add drawing code below

    But as I said you'd only get a passive flash of the object every interval.

  • cesisco

    That error is caused by pasting the paster to itself. C2 had a change that no longer permits this as it won't work on some exports as I understand it. I should change the example capx as it's affected by this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • retrodude

    I've got it working with chrome and firefox on my pc and on my android tablet. Webrts, which peerjs is based on is still in an experimental state and I think mainly google and mozilla are still working on getting a standardized spec for it. But yeah, eventually it should be useable everywhere. 50 connections at once is the limit for the peerjs server. Which is fine, as if you really needed more you could make your own server based on peerjs' server's source. A game will probably slow long before 50 players though. The main draw of peerjs is it's supposed to be fast since all the server does is act as a broker to connect two devices and then the devices can communicate directly without a server. My example is unfortunately very wip and i'm sure there are superior ways to setup the events I used.

  • So I decided to take the plunge and tinker around with some networking in C2. I found a javascript library PeerJS which uses webrtc on browsers that support it (aka Chrome and FireFox). It seemed appealing to me, as once I got a wrapper working I wouldn't need to write any server side code to get multiple devices connected together.

    So here's a relatively simple tech test of it in action. The first person becomes the host and all others connect to him. Each player has a box to drag around and all the other players box's positions are updated at an arbitrary 20fps. Supposedly I can have up to 50 players connected at once.

    So without further ado, join the box dragging nonsense:

    http://tinyurl.com/kherptw

    [EDIT]

    Nonsense indeed, after further testing I noticed quite a few things I did wrong with handling the networking events. On top of that my internet and pc are pretty slow right now.

  • tulamide sqiddster

    The plugin actually does use gl.MAX_TEXTURE_SIZE on creation and when changing the resolution. The confusion I caused was from utilizing an assert I found elsewhere that would recommend a texture size of 2048x2048 if a size was used that's larger than the max texture size. I didn't test to see what the max texture size actually was and incorrectly recalled what the size was in the assert.

  • gamepopper

    Save/load is working here. The freeze isn't a bug, it's just a slow operation to save/load the contents of the canvas. It was a feature request that has it's uses but when using large canvas' it's speed becomes impractical so the "no save" behavior is a good solution.

  • Opps, it was a typo on my end. Should be fixed, just re-download.

  • I just made a plugin that may be useful in this situation.

    http://www.scirra.com/forum/topic78654_post466046.html#466046

  • Sprite Sheet 1.0

    https://www.dropbox.com/s/ani7jkuhhcffb ... addon?dl=0

    A single image object where a sub-image can be used for drawing.

    For lack of a better description it's like tiledbg with image offset but without repeating textures. It should be useful in situations like this:

    http://www.scirra.com/forum/request-til ... 75513.html

    cheers

    [edit]

    One thing to point out is this object's "load image url" action replaces the replaces the object type's image not just the instance's like sprite and tiledbg does. So only one image per object type.R0J0hound2013-10-26 19:38:27