R0J0hound's Recent Forum Activity

  • If you pick the object you want to duplicate and store sprite.asJson in a variable, you can then create a new sprite and use the “load from json” action to make the new instance identical. You’d then manipulate the new instance as you see fit.

  • The process of making a programming language is basically the same as in any other programming language.

    Design the language and all its features on paper.

    Write a parser to take some text and convert it to tokens and then error check that there are no syntax errors.

    As you parse it you’d want the result to be formatted in a AST or RPN stack. Basically some kind of structure to be able to refer to.

    Then you’d need to run it piece by piece. The whole time you’ll be changing a program state.

    Finally there’s a high amount of tweaks and polish you can add.

    Do to the limited features of the event sheet you’ll have a bit more work to Add some features.

    Basically there’s a lot to it. And how you do it varies greatly depending on what you want your language to be and do.

    It’s interesting though, just not too trivial a project in many cases.

  • So I explored further the feasibility of doing this within the running game. Here's the current test:

    ucd7cca956b9bc75de9ee752f09b.dl.dropboxusercontent.com/cd/0/get/CiA3nMPoSPbwBh4a9QQJjV2lMO_PAIhe1IJ4rBDZeXh92aKIyt82Brs5fiPHp55vYhLRsG6GZ47-jGzyC0uwFUfQ-r85x0c3OQ40paWPhop6OtG45KJrwLC6SPA5hi7aT5E/file

    It's piecing together the necessary parts and very wip atm so it's a bit messy. Mostly a lot of asynchronous calls. A final step if I works well will be to simplify everything best I can.

    What it does?

    It can show a open file dialog, load a capx file as a zip and access files inside.

    I also was able to make it save the zip again. It's not possible to show a SaveAs dialog from JavaScript so it just invokes a download of the file. Maybe if I decide to go the nwjs route...

    The file I decided to open was the .caproj file since it has a list of the layouts, and I wanted to see how easy it was to get info from a xml file. First snag was there was three garbage characters at the start of the xml that prevented it from parsing. Fixed that and found out navigating xml is a pain. I tried doing it with the xml plugin and in javascript. Also the xml plugin doesn't let me modify data, only read it.

    So I made a converter to convert the xml to json so it's easier to navigate, copy and modify in various ways. The plan it to also convert it back to xml when done if I want to save changes.

    What is left to do?

    * Convert the json back to xml for saving.

    * Do some manipulation of instances on a layout. Initial things I had in mind were changing positions, duplicating instances, and destroying instances. Probably will make a simple ui for that purpose.

    * Save a completed new capx file with the modifications.

    It's mostly all done in js, and doing it in a plugin would be too restrictive, and doing it in straight events would take too long and be slow and hard to reuse.

    Anyways cheers.

  • That would still minify in your plugin and not work.

    The way c2_callFunction is defined it's name will not be minified. That doesn't stop the minifier from minifying the name as you're calling it in your plugin though. Basically you use object["name"] instead of object.name to keep "name" from being minified.

  • It's defined in c2 as window["c2_callFunction"]. C3 is probably defined the same way.

    So if you're calling it from a plugin and want it to be minify safe use:

    window["c2_callFunction"]("my function",[])

    instead of

    c2_callFunction("my function",[])

  • In c2 here is the flow

    construct.net/en/forum/extending-construct-2/javascript-sdk-32/order-of-update-calls-91514

    So as said above when a plugin/behavior runs depends how things are implimented.

    However as a rule of thumb I go by a simplified flow:

    1. Run plugins and behaviors

    2. Run events

    3. Run certain plugins and behaviors

    4. Draw

    5. Repeat

    For the most part most plugins and behaviors run in 1, but a few (such as drag drop as well as part of the platform behavior) run in 3.

    I guess over time I’ve created a mental list about the exceptions or I just recreate the behavior with events so I know exactly when it runs.

    Guess I should also read your big report.

    -cheers

    Edit:

    Read your bug report. That’s a bit different. Most actions are immediate in that they change things there and then. Some actions, probably for performance reasons, delay actually updating till that plugin is run or drawn.

    Anyways with the tiledbackground offset being delayed I can’t say I’ll use it much. I do my best to avoid off by one frame things like that.

  • Yeah, they removed them with the new forum update. I’ll see if I can find the post about it.

    Edit:

    construct.net/en/forum/scirra-website/website-issues-and-feedback-35/cant-access-private-messages-135322

  • The angle expression does that already.

    angle(0,0,x,y)

    Is the same as

    atan2(y,x)

  • It’s twice as fast because the timestep is set to 1/30 by default. Setting it to 1/60 will be closer to par. You can also set the stepping from fixed to frame rate independent but it seemed to make things more unstable.

    That’s no good it crashes. Guess that goes along with not setting position and velocity for best results, which includes angles.

    Sounds like something that would need to be fixed in the library itself.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Best I can tell you just need initializeAsync to finish before calling any other functions.

    So in the “then” you could call a c2function and enable a group of events there. In that group you’d update the progress and when it’s 100% call startGameAsync. Only caveat to consider is if your game finishes loading before you enable that group. Probably a trigger once condition in the group comparing loading progress to 100 should do it.

    I don’t know if it is it’s own progress bar or what. It doesn’t seem to be a requirement before calling startGameAsync, but its pretty painless to just set progress to 100 before calling that.

  • If you use the browser object you can load the js library with

    $.getScript(url, callback)

    Callback is called when the library is loaded.

    I like to have it call a construct function when it’s done. So you’d place this instead of callback:

    function(){c2_callFunction('c2functionname')}

    So then when that function was called you can run basically the js you have in the script tag. Instead of the vars just call a different c2 function.

    In that c2 function you now know that everything should be loaded and you can access the stuff the vars in your events did.

    Set text to browser.execjs("FBInstant.player.getName()"

  • It probably is more involved than it appears at first glance. Mostly tedious.

    Layouts in capx files are in a xml format and if you add more layouts you’ll need to modify the project.xml in the capx to add it to the layout list.

    Modifying layout xml files instead of just creating them are more involved. Probably would require parsing the entire layout, and then you’d have to decide what to remove or add. A easier bet is to save everything from in game and just recreate a new layout xml.

    So you can still save your game in json or whatever but it will ultimately need to be recreated in xml in the format the construct2 uses. Save your game as a folder or open your capx as a zip file to see how these xml files are formatted. As an exercise see if you can duplicate an instance. Basically that’s all you’ll be doing to generate a layout, or rather that’s what a program will be doing.

    Anyways the basic flow is:

    1 save to a file from your running game.

    2. Close the capx in construct

    3. Take that file, generate the layout xml and insert it in the capx.

    The closest I’ve done before is to take a tiled file and create a layout.xml with a sprite per tile. This pre-dated the tilemap plugin. It was more of a one shot thing though, so I did a lot of it manually.

    It’s an interesting idea though.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound