Click on button seems to lag

Get help using Construct 2

Post » Thu Mar 21, 2013 7:37 am

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.
B
9
Posts: 44
Reputation: 570

Post » Thu Mar 21, 2013 8:21 am

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.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Thu Mar 21, 2013 8:28 am

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.

https://www.box.com/s/g8wva860dbs6nd7ilb63

Thank you :)
B
9
Posts: 44
Reputation: 570

Post » Thu Mar 21, 2013 8:50 am

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.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Thu Mar 21, 2013 9:52 am

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.
B
9
Posts: 44
Reputation: 570

Post » Thu Mar 21, 2013 10:11 am

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]:


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


Resized image to fit in-game [61x153px; 5KB]:
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Thu Mar 21, 2013 10:59 am

Thank you so much for the tip!

I tried it out, and it definitely improved the loading time to change to the next layout. :)
B
9
Posts: 44
Reputation: 570


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Braus, supreme676 and 8 guests