Johncw87's Recent Forum Activity

  • If you see the above code, the majority of it is eval statements and console logs. Me and the chrome debugger spend many hours together every day. All javascript objects are populated correctly, but return values all return '0' for all arrays/dictionaries on get/haskey. Unless you can tell me how to specifically watch the process where the C2 engine is getting this 0??

    Well lets start off by finding the code for the Dictionary 'Get' expression. It would, of course, be in the plugin for the dictionary. That means it will be in Dictionary_plugin.js (in preview mode). Looking through the file, you can see all kinds of function definitions for the conditions, actions, and expressions. Eventually you will see this:

    Exps.prototype.Get = function (ret, key_)
    	{
    		if (this.dictionary.hasOwnProperty(key_))
    			ret.set_any(this.dictionary[key_]);
    		else
    			ret.set_int(0);
    	};
    [/code:19c4bika]
    
    So if it can't find the key, it returns 0. Why can't it find the key? A quick google search tells me that hasOwnProperty is a built in javascript function that tells you if a value exists on an object. So how do we know if the value exists? Set a breakpoint on the line that calls hasOwnProperty, and trigger your broken event (Firefox seems to be really bad at setting breakpoints, use Chrome for this). The browser will stop the game when it calls the Dictionary Get expression (from any part of your event sheet). At this point, hover your mouse over the 'this.dictionary' text, and it will show you all the values that are in it, and if you hover over _key, it will tell you what value it is trying to get. You may be looking at any one of the calls to this function that your event sheet triggers, so it may or may not be the one you are looking for. If not, tell the browser to continue, and it will show you the next call. What you do from here depends on what you find out.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you look I also had to make buffer variables to hold on to the parameters because the parameters DISAPPEAR!!!!! if I try to use them in a sub event. I am completely not understanding scope or how this works or something.

    Well this is an easy one. Functions are triggered events, and function parameters are only good during that triggered event. But when you use a wait action, everything that happens after it is no longer inside that triggered event. It has been scheduled to run at a later time, and then does so. It does not matter that the wait time is 0.0 seconds, it will still kick the following actions and sub-events out of the triggered event and cause function parameters to fail.

    As for your dictionary problem, my recommendation is to get very friendly with your browser's javascript debugger. Run your project in preview mode, and try to find the javascript functions that correspond to the condition and expression that are failing. Set a breakpoint in them right before you trigger something that you know isn't working properly. Then try to use the available information in the debugger to see why it isn't working.

  • I tried to add a comment here, but I get a message about how it "looks like spam".

    http://www.scirra.com/arcade/action/175 ... o-bros-1-1

    This is the comment I tried to post:

    > Perfect . How did you do that?

    >

    With lots of care and effort.

    For Mario's movement, I referenced an image I found that detailed his various speed and acceleration values for every possible state. I also wrote a Lua script for FCEUX which would show me the position and speed values of enemies in real-time. For more complicated behaviors like Bowser, I referenced a disassembly of the game. For most everything else, I stepped the emulator frame-by-frame to carefully observe the game's behavior.

    If you are interested in the source, I recently uploaded it to Mario Fan Games Galaxy.

    I don't see how this could "look like spam". This also happened with another game I tried to comment on (the really horrible Mario game that is somehow in the top 5 on the arcade). I think the website may have banned me after this last attempt to post a comment.

    Could Tom or Ashley look into this?

  • What I would like is the ability to mark events and actions with some sort of marker as so

    *image here*

    in order to specify whether or not the code will only be active in debug mode only, and left out of any export version.

    There is already a condition for this. It is called "Is in preview".

  • Here we go again, another bug with this condition!

    Problem Description

    If a non-looping music file is allowed to play to completion, the All Preloads Complete condition will never become true.

    Attach a Capx

    https://dl.dropboxusercontent.com/u/207 ... test3.capx

    Description of Capx

    Starts layout 1. Sets text to "Preloading". Waits for preloads to complete. Starts to play Music1. Sets text to "Preloads Complete". Waits 6 seconds. Goes to layout 2, and repeats all the previous things (but with Music2).

    Steps to Reproduce Bug

    • Run capx preview in FireFox.
    • Wait 6 seconds
    • See layout 2 stuck on "Preloading"

    Observed Result

    After playing Music1 and changing to layout 2, text gets stuck on "Preloading"

    Expected Result

    After playing Music1 and changing to layout 2, text shows "Preloads Complete" and Music2 starts playing

    Affected Browsers

    • Chrome: (NO)
    • FireFox: (YES)

    Operating System and Service Pack

    Windows 7 Home SP1 (64 bit)

    Construct 2 Version ID

    Release 178 (64-bit)

  • Problem Description

    The "All Preloads Complete" condition becomes true too early on Chrome for Android

    Attach a Capx

    https://dl.dropboxusercontent.com/u/207 ... test2.capx

    Description of Capx

    Preloads a long sound, waits for preloads to complete, and then plays it. It also tries to grab the duration of the sound.

    Steps to Reproduce Bug

    • Preview the capx over WiFi.
    • Use Chrome for Android to view the preview
    • Observe result.

    Observed Result

    Preview reports that preloading is complete, and the sound duration is 0. Shortly after, the sound begins playing.

    Expected Result

    Preview reports that preloading is complete, then reports the sound duration as 25.5557918549 (or something close to that) while simultaneously playing the sound.

    Affected Browsers

    • Chrome: (NO)
    • FireFox: (NO)
    • Node-Webkit: (NO)
    • Chrome for Android: (YES) (Also affects Crosswalk export)
    • FireFox for Android: (NO)

    Operating System and Service Pack

    Windows 7 Home (64-bit)

    Android 4.3 on a Samsung Galaxy S3

    Construct 2 Version ID

    Release 178 (64-bit)

    Also tested Release 177 (64-bit), still a problem there.

    Additional Notes

    If I remove the 0.5 second wait after preloads are complete, it will often report the duration as 0 on the above browsers that I state are not affected. While this is not a big issue for me, it may be a problem for someone else at some point.

  • re: "Not possible"

    I agree. With the right parameterization it can be done, but it would involve other tradeoffs, such as larger event sheets and more parameterization -- which makes the code less understandable.

    re: duplicate code

    I surely understand the "evil" of code duplication. However, during prototyping, code duplication can save significant time and cost -- even if i systematically need to make changes across several event sheets -- and I have to do this rather frequently. These event sheets are btw easy to spot since code duplication is only needed for very similar layouts -- such as when "AB" testing layouts ...

    Well, at the beginning of this very thread, you asked for advice on production quality code, and that's what I'm giving you. And I beg to differ on parameterization making it less understandable. Consider the example I edited in to my previous post.

  • Since the quiz I am constructing has layouts that are significantly different its not possible to have a common event sheet for all. Instead, I turned it around, extracting commonalities to sheets included in all layouts.

    It is very likely that you can, in fact, use the same event sheet for all of your quiz layouts, despite them being "significantly different". The levels in Super Mario World are "significantly different", and yet they all use the same code to run them. "Not possible" is a rather bold claim, one that likely wouldn't stand if you were to post your capx.

    I rather duplicate code than write parameterized code.

    I strongly disagree. Code duplication is one of the evils of programming.

    If you need to fix a bug, or change how it works for any reason, you have to remember to do it in all the places where you copied it. You will inevitably miss a spot or two, and have bugs that you already fixed show up in very specific situations.

    "Parameterized" code is also better for readability. What is easier for you? Reading this:

    sqrt((Player.X - Enemy.X)^2 + (Player.Y - Enemy.Y)^2)

    Or this:

    distance(Player.X, Player.Y, Enemy.X, Enemy.Y)

    With the distance function, just glancing at it tells you what it does. With the formula code, you have to spend more time on it figuring out what it does.

  • 1. Internationalization

    My quiz needs to work in more than one language. At this stage I developed a simple but not too efficient solution for that. What do professionals do in cases like this.

    The Source engine (which is used for several first-person shooter games) references multi-language strings with special identifiers. Day of Defeat has one that looks like this: #Dod_Join_Team. An external language file is used to replace the identifier with the language specific string. For Construct 2, I think you should use a dictionary object, whose keys are the language identifiers, and the values are the language specific string. Load the dictionary contents from an external file (such as lang-en.json, lang-es.json, lag-de.json, ect). Then, at the start of every layout, retrieve the language string from the dictionary and use it in the text objects.

    2. Dealing with common pre- and post- processing during each game segment.

    In the quiz there is code that needs to run before and after every quiz screen, example, to start and end timing the quiz length of time. I am currently using a call back feature and include sheets, and a guideline how to construct a main event sheet (always e,g, include eventsheet pre-post). Are there better ways to do this

    You should try to have all of your quiz layouts using the same event sheet, with any differences that are needed specified in the layout in some way. Since layouts don't have variables, I create an object specifically for this purpose (I call it 'LevelProperties'). Give it some instance variables, and configure them as you see fit for each layout. Have your events reference these variables to handle the differences.

    3. Global variables

    It turned out that I have a lot of global variables. I am not sure this is good practice. Do professionals avoid global variables, if yes are there different techniques for that (i know of static local ones, is this used extensively)?

    Personally, I try to avoid global variables whenever possible, since they clutter up the combo box for selecting a variable. If you can get away with using a local, do so.

  • Event sheets also have this problem. If you collapse an event or group, then it writes a collapsed="1" attribute into the event sheet xml. This belongs in the uistate.xml.

  • If your sprite is a global object, you will probably need an explicit event telling the pathfinding behavior to regenerate the obstacle map when the new layout starts. You will also need to do this if an obstacle is moved, created, or destroyed.

  • I uploaded something to the Arcade, only to find that the json file I was using with the AJAX plugin didn't work. So I created this test:

    http://www.scirra.com/arcade/example/17594/ajax-test

    The problem seems to be that while the json file passes the file whitelist, it never ends up on the server. This link is a 404:

    http://static1.scirra.net/arcade/games/17594/test.json

    As a side note, txt files are not on the whitelist, and I find that a tad silly.

Johncw87's avatar

Johncw87

Member since 21 Feb, 2014

Twitter
Johncw87 has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Viral Game One of your games has over 100,000 players
  • RTFM Read the fabulous manual
  • x2
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

18/44
How to earn trophies