Toby R's Forum Posts

  • - Honestly I would LOVE for it to be my bad programming, but if I disable all of my code the fps doesn't really change much. Unless, however, disabling is different from actually deleting it.

    If after disabling all of your code you still have performance issues then I assume you have a lot of (probably high res?) sprites with motion behaviors? I saw once a project with many high-res grass objects with sine + effects + the grass had 60 frames animation. This in result was killing the project as both behaviors and 60fps animation takes a lot of CPU.

    There's really a lot of things that can affect performance. My advice is to disable/remove features/elements one by one and check what's the issue. Then once tracked think of how can you optimize it.

    C2 is surely not a performance beast and that's why it's difficult to make a big project and so - important to code/make it carefully.

  • I am a full time Construct 2 freelancer and I've completed many projects for browser, desktop and mobiles. Apart of making games from scratch I also had many requests from my customers to finish/optimize their game.

    After several years with C2 I can clearly say that the most common performance issue with C2 is not a GPU but the C2 developers (or I should rather say their code). Of course GPU, CPU, your machine and C2 itself also takes some part in the performance issues but the majority of issues I saw was the C2 code (I mean the events of C2 devs projects).

    C2 is pretty much like JavaScript or PHP or any other language that is not very strict from architecture perspective. What I mean is that it is very easy to make a simple things with C2 (like in JS for instance) but it is really a big challenge to make a big projects the right way.

    The problem is (as mentioned above) the architecture freedom. So while making a big game people tend to use the same coding approach as for small games and in the end they are lost in the messy code which is totally unoptimized as you don't really need to care for optimization in small projects.

    With big projects it's different. There's much more code/events so much more operations for CPU and therefore you must use the best coding practices so each feature uses the least CPU as possible. And next to that you need to keep your code architecture very organized to not get lost in your big project (and that is also not very easy with C2).

    It also depends on what you call a big project. I worked with projects made of several thousands of events and after optimization they worked well on majority of modern desktop devices. Still the bigger project, the bigger challenge.

    So to wrap up, in my opinion it is possible to make a big project (not sure about a huge one) in C2 in a way to make it work very well, but it's not an easy task. Definietely not a task for a C2 newbie. It needs experience and deep understanding of how the memory managament works in C2, which conditions are the real triggers and which are fake triggers, what takes the most CPU, how to make workarounds for high CPU intensive parts etc. Without all this knowledge you will probably fail in making a big game in C2 as C2 is simply difficult for such projects.

    From the other hand if you pick Unity or any other engine you also need to learn how to use it properly.

    EDIT: Just a clarification as I received some PMs. Please note that I'm not saying that performance issues are not related to the C2 itself at all, I'm just saying that the most common issues comes from the bad coding.

  • I can reproduce this as well. Could it be related to the fact that C2 editor works faster when you have your object in the subfolder?

  • Very nice plugin, im currently using every feature of it ... but i have a problem! GetTimestamp gives me an error, while GetFullTimestamp is working just fine. Can you look into this?

    EDIT: SHA256 gives also an error on use, while the other both work.

    Thanks for letting me know! I was refactoring the plugin earlier and made some silly mistakes. Please download the latest version. The bugs are now fixed.

  • For example you could use 10 static locals inside a group, when only just that group uses them, and they never appear anywhere else in the event system, and the variables themselves are close to where they are used. I think this is an under-used feature and would do a lot to solve the "global overload" problem..

    That's exactly the point and I have mentioned that in my article as well. Whenever it is possible you should encapsulate your project as much as you can. The code architecture is crucial in development, especially for big projects.

    Then if you still need some variables with global reach the Globals plugin comes handy.

    you are free to use any of my free plugins in your commercial and non-commercial projects without any restrictions. You are also not obligated to credit me or something - it's fully free.

  • Okay, so I managed to make a quick&dirty "hotfix" for this issue. The point is that the handshake message is sometimes not fetch by C2 code for some reason. So I tried to reattempt the handshaking and it works with every second handshake attempt on my end.

    So basically something like that:

        var isWelcomedByTheScreen = false;
        var handShakeReattempt;
    
        var sendHandshake = function () {
            if( ! isWelcomedByTheScreen)
            {
                console.log('sending handshake');
                airConsole.message(AirConsole.SCREEN, {
                    handshake: true
                });
    
                handShakeReattempt = setTimeout(function(){ sendHandshake() }, 700);
            }
        };[/code:1o2tg1ho]
    
    Now when you finally receive confirmation from the Screen:
    [code:1o2tg1ho]
                        if( ! isWelcomedByTheScreen)
                        {
                            console.log('welcome received');
                            clearTimeout(handShakeReattempt);
                            isWelcomedByTheScreen = true;
                        }[/code:1o2tg1ho]
    
    I presume this issue affects all C2 AC apps, so here's the easy workaround for now.
  • Will do - thanks again

  • Well, I cannot say much because I also do have these issues sometimes. What I can say for sure is that I never had them using an android device, but one of my team mate has an older iphone and an ipad that does that like.... all the time.... I don't know how you handle the JS on your controller, but seeing the identation it looks like that part of the code you shared is under something, I think you instanciate AirConsole under $(document).ready() ? I increased the perfs a lot doing it that way. Something you should try, to see if any difference is actually upload your game without putting it in review, so you can preview it. Usually a lot of things gets fixed doing so

    Ah, then it might be something in the AC API actually. I was suspecting that as well. My controller is quite big so I spread the code across several classes that's why the indentation.

    Alright. Thanks for getting back!

  • Are you having these issues while using the simulator or in production?

    Using a link via their site: http://www.airconsole.com/?http=1#http://my.server.com/

    EDIT: Just checked simulator and all works perfect there. That's interesting.

    EDIT2: Ah no it's not... after more tests it start to have the same issue in simulator.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Before I go further with debugging I thought it might be some known issue so I'll ask.

    When I test my game with two controllers, the first one always connects properly as it receives the handshake trigger from the screen. Second controller however has like 50/50 chances to connect or not. It is connected to the airconsole (icon visible in top right corner) but "On device join" condition is not being triggered and so the controller is not connected to the game.

    I've debugged the controller and it is sending the handshake to device 0. I use the standard part in my controler for that as below:

    var airConsole = new AirConsole({orientation: AirConsole.ORIENTATION_LANDSCAPE});
        // var rateLimiter = new RateLimiter(airConsole);
    
        var sendHandshake = function () {
            airConsole.message(AirConsole.SCREEN, {
                handshake: true
            });
        };
    
        airConsole.onReady = function () {
            sendHandshake();
        };
    
        /** -------- AIR CONSOLE MESSAGES --------- **/
        airConsole.onMessage = function (device_id, data)
        {
            if (data.handshake) {
                sendHandshake();
            }[/code:22c9mr75]
    
    I also put just few quick logs to the runtime.js of the plugin and "[i][u]this.air_console.onMessage = function(device_id, data)[/u][/i]" is not even triggered, therefore it can't process the handshake.
    
    So simply saying, if the screen broadcasts  "Game is ready" then controllers connect, but when the screen is already loaded and it's the controller who sends the handshake, then it's like 50/50 that the Plugin will catch it.
    
    I'm using AirConsole plugin v1.4.8.1
    
    Are you maybe familiar with this issue  @Psychokiller1888?
    
    Thanks
    
    ==EDIT==
    Updated to newest plugin version. Still same problem. Screen just logs in console that "WebRTC active for device_id 2", but the plugin is not triggering anything.
  • By consuming a purchased product you basically allow user to purchase it second time (like extra coins which they can buy how many they want for instance). So in your case you don't want to consume the product. Once it is purchased it should not be possible to buy it second time as user already owns it and it has its "has" state set to "true".

  • As you already digged up this topic, I'd like to mention that there's a new TR_System condition Is value in set which makes such things even easier.

  • I assume you use Cranberry's plugin as Scirra's IAP plugin doesn't even have this feature. Or you use Cocoon plugins?

    Either way consuming should work when you just run "consume" action after purchasing the product so if it doesn't then I suggest to contact plugin's author as this technology changes frequently and plugins require constant updates.

  • I don't remember I ever said that C2 global variables are dangerous in any way.

    Well, if one has a global var which value change can unintentionally make a mess on the runtime then it means his code architecture is crying a river.

    Please read my article linked in the first post here. I think it will clear things out for you.

  • I understand why having a Global Variable the user can't change freely during game play is considered a problem.

    I have global variables that the user can freely change in game settings or game play, are these considered unsafe Global Variables? They are limited by conditions and only effect the player changing them.

    I'm sorry but I don't understand what you mean exactly. You can change global variables during gameplay and they are safe to use from security perspective... and I think you know that... could you please rephrase your question?