Toby R's Forum Posts

  • Where exactly have you stucked? You can load data for example using AJAX if it is a PHP output. Then parse output to string without "new line" characters and set it as a value of your text type instance variable.

  • There were several topics regarding this issue, but no perfect solution. What work best for me is:

    1. create a global layer "Layout Loader" as a top layer (it can be a blank layer or layer with pretty sprite saying "loading in progress" - whatever suits your app)

    2. set its "initial visibility" to "visible" by default

    3. just before jumping to the next layout set its "initial visibility" to "visible" (no it's not a mistake, yes I know I just wrote that in point 2, but just keep on reading)

    4. On start of layout (every layout) loading screen is still visible because "Layout Loader" is visible by default. Thanks to this user won't even notice when the layout switches. At this time C2 engine loads everything what's below the loading screen (so it basically loads a layout).

    Now the good question is "when should I hide the loader screen?". Well you can set some static time with wait function and hide it after - let's say - 6 seconds.

    OR

    You can be a bit smarter and check when the loading process is done. There is no built in solution to check that (at least I am not aware of it), but you may use the "fps" value. On start of every layout FPS drops drastically because of loading and rendering initial objects.

    So you can do something like:

    Every 0.3 seconds -> add 1 to "timesChecked" (this is some local static variable)

    if FPS >= 30 (let's assume 30 FPS as a minimum fine framerate)

    OR

    timesChecked >= 20 -> hide "Layout Loader"

    So the "Layout Loader" will be hidden as soon as the FPS will get high enough to play game smothly OR after 6 seconds (timesChecked*0.3s). Second condition is important because some devices (older mobiles for instance) might never get 30 FPS even if everything gets loaded and would be stucked with loading screen forever.

    This is ofcourse a short example and you can upgade it a bit in a various ways, but I believe you get the point now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a workaround solution. Just go in and read.

  • I never had such problem so I'm not very familiar with this topic, but the first thing that came to my mind was pixel rounding project property. Do you have it ON?

    From the manual:

    [quote:3s84v972]Pixel rounding

    By default Construct 2 objects can be drawn at sub-pixel positions, e.g. (100.3, 200.8). If the browser is using linear filtering, this can make fine pixel art appear blurry. If Pixel rounding is set to On, Construct 2 objects round their position to a whole number before drawing, e.g. (100, 201). This prevents any blurring, and can also prevent "seams" appearing on grids of objects. Note this does not affect their actual X and Y co-ordinates, which can still be between pixels - it only affects where they are drawn on the screen.

    https://www.scirra.com/manual/66/projects

  • There is some old discussion about that. I haven't tested it but you might find it helpful https://www.scirra.com/forum/publishing-on-google-play-50mb-limit_t105998.

    Also in this discussion shinkan rised a suggestion

    Yeah, possibility to add extensions in C2 would be really nice.

    Google Play allows you to upload 50MB size APK and 2x2GB size extension files which should contain media files and all assets. This would be really nice to have sucha possibility, because at the moment we are kinda limited to 50MB where nearly half of that takes current Crosswalk (14) version.

    Ashley, is it possible to implement this in C2 or it's more like Intel XDK case? And if it is, can you tell us if you guys have it in plans for C2 or at least for C3?

  • I don´t have C2 around currently, but you could set the animation frame to "int(random(x))". That generates a random number between 0 and X.

    "int(random(x))" will generate a random number between 0 and X, but 0 and X will have 50% less chances to be generated comparing to all the numbers in between.

    It's better to use "floor(random(x+1))" if you need a range between 0 and X.

    OR

    "floor(random(b-a+1))+a" if you need a range between A and B.

  • "floor(random(b-a+1)) + a"

    This gives the most equal chances to return an integer number from "a" to "b" (including them).

  • But you haven't describe what exactly problem do you have?

    First one is spawning.

    Spawning an object you can do by System -> Create object or by some sprite object -> spawn object.

    I need to spawn a car at random 1-3 seconds...

    You can use "Every x second" or any other loop with "wait" function, but there is a special way you have to build a delay between iterations. You can learn it here: https://www.scirra.com/tutorials/723/using-wait-in-loops.

    Regarding random function, the most precise is the following format: "floor(random(b-a+1)) + a" which returns an integer number from "a" to "b" (including them).

    and also spawn different types of cars (as I have different coloured cars and I don't want them to be the same).

    If the only thing which differs is the color then I encourage to use one sprite and put various cars as separate frames.

    Second thing is stopping. once the first car is stopped, the car behind goes ontop. I know I could put collide but I want there to be a gap inbetween the two.

    Well this really depends on how exactly your game works. You can for instance check the distance between car1 and car2 by X and Y position.

  • I'm 99% sure objects in family are reference to the oryginal objects, not their clones. Reference takes literally several bytes so it can't affect performance even if you have hundreds of thousands of them in your project.

    But I might be wrong, and C2 developers made it differently for some reason. If you have time you can test performance with - let's say - 100 different objects doing something in every tick loop. First test it without family and then put all of them to the family and run the loop again. If there will be no difference in FPS for 100 objects then it's ok I think.

  • Glad I could help .

  • Have you built it with Crosswalk? And have you uploaded both ARM and x86 APK's to Google Play? 270 devices sounds for me like you have uploaded only x86 APK.

  • For the random number it is better to use "floor(random(b+1))" (or "choose" function if you don't have many numbers to choose from) instead of "round(random(a,b))".

    round(random(a,b)) does not generate numbers equally, border numbers (a and b) have 50% less chances to be generated than the numbers between "a" and "b".

    EDIT: it should actually be "floor(random(b-a+1)) + a" if you want a range between f.ex. 5 and 10. What I've mentioned before is for ranges starting from 0, like 0 to 10.

  • You can use any loop, but there is a special way you have to build a delay between iterations. You can learn it here: https://www.scirra.com/tutorials/723/using-wait-in-loops

  • You can do a workaround with a small PHP script.

    <?php
    header("Access-Control-Allow-Origin: *");
    $rss = file_get_contents('http://undeadbobop.blogspot.com/feeds/posts/default');
    die($rss);
    ?>[/code:qkpa54jm]
    
    Now you can grab your PHP file with AJAX in C2. The result will be the same.
    
    EDIT: I'm sure both solutions will work on most of free PHP servers.