Slowing with lots of images

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

Slowing with lots of images

Post by cwkalish » Wed Jan 07, 2015 2:58 pm

I have a game that puts a lot of fairly detailed images up on the screen at the same time. Things slow down quite a bit as the number of images go up-- on an android tablet things get very laggy.

Is there a way to reduce the processing demands of displayed images? The images aren't doing anything, they are just sitting there.

Thanks.

_Chuck

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Slowing with lots of images

Post by dave.kilroy » Wed Jan 07, 2015 7:17 pm

hi _Chuck

I would say do what you can to minimise memory use. Are you having to resize images? If so consider resizing them before including them either as referenced or imported images. Are you displaying copies of the same image several times in your GUI? If so consider using a technique such as using buttons in place of images and set their icons to a single copy of the image. What about resolution and file size of the images can they be reduced? Last thing I can think of is whether you have groups of images that can be turned into a single image?

Another thing you can do is to take a snapshot of all your images on your GUI, display this single image and delete all the images (but this might not work depending what you might want individual images to do later on...)

And what exactly is 'laggy'? Are you making use of 'lock screen' during moves/transitions?

Dave
"...this is not the code you are looking for..."

cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

Re: Slowing with lots of images

Post by cwkalish » Wed Jan 07, 2015 8:23 pm

Thanks for the suggestions. Those are just what I was hoping for. I think the button icon may be the ticket: I have lots of copies of the same image.

How do I get an image to be a button icon?

The snapshot idea is cool too-- The images don't move so I don't really need them to be separate (they just appear 1 at a time).

By laggy, I mean that simple scripts take a very long time to execute. There is a big delay between clicking on a button and having fairly simple things happen. It gets increasingly worse as more images are displayed.

Thanks again.

-Chuck

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Slowing with lots of images

Post by dave.kilroy » Wed Jan 07, 2015 8:40 pm

import you single image to your stack (could be on a separate 'resources' card)
save your stack
create a button
with the button selected open the inspector and go to the 'Icons & Border' tab
click the 'wand' image to the right of the 'icon' box
change the image library to 'This Stack'
find the image you just imported among the grid of images
click OK
uncheck the following items: threeD, showBorder, hiliteBorder
go to the 'Basic Properties' tab of the inspector
uncheck the following items: opaque, showName, autoHilite, sharedHilite
go to the 'Size & Position' tab
click the 'fit content' buttons for width and height

BTW the above assumes that in LiveCode's Preferences, in the General tab, that you have 'Property labels' set to "name of LiveCode property"
"...this is not the code you are looking for..."

cwkalish
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 78
Joined: Thu Sep 30, 2010 2:24 am

Re: Slowing with lots of images

Post by cwkalish » Wed Jan 07, 2015 9:35 pm

Great. Thanks. And I can change the icon just by setting the icon property to the short name of a different image.

Just redid with buttons and things move much faster.

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Slowing with lots of images

Post by dave.kilroy » Wed Jan 07, 2015 9:46 pm

glad you're getting improvements already (most likely other optimisations you can do as well).

To change the icon either do it through the gui in the button's inspector or programatically with

Code: Select all

set the icon of btn "btnThisButton" to 1234
(where 1234 is the id of the image)
"...this is not the code you are looking for..."

rickychou
Posts: 2
Joined: Fri Jan 23, 2015 7:51 am

Re: Slowing with lots of images

Post by rickychou » Fri Jan 23, 2015 3:59 pm

yup, it's always that slowly when i use samsung tablet T.T I will try your solution, hope it works

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Slowing with lots of images

Post by Klaus » Fri Jan 23, 2015 4:25 pm

We developed an image-rich (>4000) app last year and I had to use every trick I could remember
to make it work (more or less) on iOS but had to give up the Android version for the above
mentioned reasons :(

Worked fine and smooth on the desktop, not so smooth on iOS and did not even start on Android!

Post Reply

Return to “Games”