R0J0hound's Forum Posts

  • Using tilemaps sounds inefficient for that. Here's the way to do it using a layer and four sprites with the destination out blend.

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

  • [quote:3q64psj0]...without having to make C2 loop through all the instances.

    The pick nth instance doesn't loop through all the instances, it just picks the instance directly.

  • Try Construct 3

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

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

    Here's the working script for the latest nw.js:

    "var win=nw.Window.get(); win.on('close', function() {c2_callFunction('nw.js close',[]); win.close(true);});"

    I had forgot to make it actually close after the trigger. You can change 'nw.js close' to any function name you want to use.

  • There really isn't a way to do it manually. Well a very hacky way could be to have a square Sprite and a triangle Sprite. Then you take the for points and figure out how to make it out of rectangles and triangles with the requirement that the triangles can't be scaled up.

    Another could be to have four scaled sprite with the destination out blend to erase parts of a colored Sprite.

    But really those plugins add features that aren't doable with vanilla c2.

  • Here's a reference on how to do it with JavaScript:

    https://github.com/nwjs/nw.js/wiki/window

    My next question that I'll have investigate later is if you can access nw.js with JavaScript with the browser plugin.

    If that's possible we can execute a few lines of js at the start of the game that will call a c2 function when the window closes.

    Edit:

    I'll assume for a moment that you can access nw.js with the browser object.

    You'll need the function and browser objects, then execute this js at the start of the layout:

    "var gui = require('nw.gui');

    var win = gui.Window.get();

    win.on('close', function() {

    c2_callFunction('nw.js close',[]);

    });"

    Then add this event anywhere. I should be called before the window is closed.

    On function "nw.js close"

    --- do something

    If the js causes an error so it doesn't work I'll have to look into it further when I get a chance.

  • You can do that with the paster or canvas plugins. Just make either the size of the screen and use their actions to draw the polygon. If you're using webgl then paster will be faster, also with either they take up a texture usually their same size.

    If you make a plugin you can do it without the texture as well.

  • Instead of checking if it's a symbol you don't want, just check if it's a symbol you want. Do it under the "on text changed" condition, and the length can be truncated there too.

    global text allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    
    +-------------------------------------------+
    | textbox: on text changed                  |
    +-------------------------------------------+
        local text filtered = ""
        +---------------------------------------+
        | system: repeat 8 times                | system: add mid(TextBox.Text,loopindex,1) to filtered
        |System: find(allowed,                  |
        |  mid(TextBox.Text,loopindex,1)) <> -1 |
        +---------------------------------------+
        +---------------------------------------+
        |                                       | textbox: set text to filtered
        +---------------------------------------+[/code:20x8j9rq]
  • Maybe the bullet behavior and the rotate behavior with negative acceleration?

    An all event route could also look like this:

    Global number dist=0

    Global number ang=0

    Every tick

    --- add 100*dt to dist

    --- add 180*dt to ang

    --- Sprite: set position to (100,100)

    --- Sprite: move dist pixels at angle ang

  • there have been other topics for that. The equations for the motion of a falling projectile is this:

    y1=y0+vy*t+0.5*gravity*t^2

    x1=X0+vx*t

    X0,y0 is the start position

    X1,y1 is the end position

    Vx,Vy is the velocity

    t is time

    If you pick a time and then solve those equations for vx and vy that would do it.

    I think it's referred to elsewhere as predictive aiming. You could also Google kinematics for more tutorials about the equations used.

  • It's basically done with a bunch of springs. Hook's law is the equation to use to calculate spring force. Then it's just a matter of tuning the constants. So the math isn't that bad at all.

    Searching for jelly gives these two:

    The first one is more applicable I suppose. It's just a grid of point connected by a mesh of springs. Making it interact with other objects is where the most work is needed and there are many ways to handle it.

  • The general way to use values from a particular instance is to pick it with a condition the footsteps1.x will be the X of the one that's picked.

    You could also not use picking and use footsteps1(5).x to get the X of the fifth instance. But picking is probably easier to read.

    You can use an array of you like, I mean if it's easier to understand. It probably isn't needed though since the object list can be thought of as an array too. Reading the manual sections on how events work could be a useful reference.

    Generally you need global variables or global objects to pass information between layouts. The persist behavior saves an objects state so it's the same if you leave a layout and come back. If the events are overwriting the state then you'd need to rework the logic of the event sheet.

    The overall logic of your game should be pretty much the same as if you made it in any other language. My solutions are probably too terse to be useful since the logic is obscured away so it's not obvious to others.

  • When you say layer I think you mean layout. You could try the presistance behavior on the footsteps perhaps. It lets them keep their state even when you switch layouts.

    Also kind of unrelated but

    For each Sprite ordered by Sprite.iid ascending

    Is identical to

    For each Sprite

    The expression you use with the "for each ordered" is used to sort the instances before looping over them. To filter out some instances from being picked you need to use another condition. Maybe the pick by comparison condition.

  • Using the pick nth instance with Sprite.count-1 should do it.

  • Usually I just replace all the " in the js with ' which works well. To actually use " in js it looks much uglier and makes it harder to find typos.

    For example the take this js:

    var name = "bob";

    To use in c2 this usually is what I do:

    "var name ='bob';"

    But if you want to still use " it looks like this:

    "var name=""bob"";"

  • The manual explains the conditional operator pretty well here:

    https://www.scirra.com/manual/78/expressions

    But yeah, it's like a simple if then else.

    If X=2

    Then set y to 4

    Else set y to 5

    Can be written instead as

    Set y to X=2?4:5