Click on button seems to lag

0 favourites
  • 7 posts
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • Hi,

    How do I ensure that when on mouse click on a button, it will direct the user to the next page (layout) without any problem? I tried this method: Mouse > on Left button click on StartBtn> go to Layout 2, and it works fine on other animations, but on this particular animation I'm working on, it seems to lag and take awhile for it to load the next layout.

    Sometimes I have to click on it a few times for it to load the next page.

    I am using Construct 2 Release r120.2. I am not sure if this is the cause of the problem since this version is a beta release.

    Thank you.

  • Your method seems right, so there must be something else to take into consideration. Maybe you have a lot of stuff running on layout exit?

    You refer to animations in an odd way, what do you mean by "this particular animation I'm working on"? Is it possible that an animation is still running, causing the delay?

    Without much more info it's difficult to diagnose your issue without guessing. Posting a capx would enable us to help you easier.

  • Try Construct 3

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

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

    My mistake, I was referring to the previous animations I worked on in Construct 2.

    Can you elaborate on what you mean by having a lot of stuff running on layout exit?

    Here is a link to my .capx file.

    box.com/s/g8wva860dbs6nd7ilb63

    Thank you :)

  • I was referring to the "on layout exit" action, but looking at your capx that's not the problem.

    Still not sure what you mean by animations, unless that's what you mean by "games". Anyway, that's not an issue either.

    Taking a look through your project, I'm pretty sure that the only issue is the size of your images - in terms of disk space. They're too big. 5MB for a simple project like this is huge. The images are simply taking too long to load (as it's their first time doing so when entering the layout) when changing layouts, which causes the delay. It's nothing in your code, you just need to optimise the images in an external image editing program like Photoshop or even GIMP.

    I'm testing by compiling this project and even that is taking waaay longer than it should. My PC is churning away to make those sprite strips.

    Your other option (which doesn't actually address the problem, it just side-steps it) is to include all or at least half of your images in your first layout, but just outside of the layout itself so they won't be visible. This forces the browser to load the artwork into memory in stages, instead of all at once. This won't reduce the overall lag, but it'll slice it into less noticeable chunks.

    Oh, and you don't need to use both the mouse and touch object for input. Touch has a neat property called "use mouse input" which simulates the use of a mouse, meaning you can use the touch object exclusively but it'll accept both mouse and touch input.

  • Hi!

    Thank you for your reply.

    Regarding the size of the images - in terms of disk space, do you mean, I will have to edit the images to smaller size? I am not so clear about this part.

  • Yup, you'll have to edit the images to smaller size.

    Read about image optimisation here.

    You can see that file size is determined by a variety of factors. In your case, decreasing the dimensions of the images will greatly help in reducing file size. You seem to be using massive images but actually resizing them down greatly in-game. This still uses the original image, however (and additionally has to calculate resizing it, which also looks pretty ugly in C2), so you're effectively wasting space.

    Example, your iodine bottle:

    Original, actual image [703x1770px; 47KB]:

    <img src="https://dl.dropbox.com/u/14522925/C2%20examples/bottle-actual-size.png" border="0">

    How the image appears in-game [61x153px; still 47KB]:

    <img src="https://dl.dropbox.com/u/14522925/C2%20examples/bottle-in-game.png" border="0">

    Resized image to fit in-game [61x153px; 5KB]:

    <img src="https://dl.dropbox.com/u/14522925/C2%20examples/bottle-resized.png" border="0">

  • Thank you so much for the tip!

    I tried it out, and it definitely improved the loading time to change to the next layout. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)