Image loading delays

tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
edited September 2017 in Working with GS (Mac)

I'm making a yearbook sort of app where you can scroll through pages of photos with names. This is all in a single scene with 25 actors with no images (to start with). I'm changing their self.Image values to match images in the Library whenever the left/right page actor is clicked. Each image is about 700 KB and they are all jpegs. It takes about three seconds for all 25 of the images to change (at once) when I "switch pages." After I've done that once for each "page" of 25 images, I can navigate between "pages" as quickly as I want and the images change immediately.

I'm wondering if there's a way to prevent the initial delay. I tried checking or unchecking Preload art which doesn't seem to matter (makes sense since technically the actors have no image values to start with). I also tried looping through all possible image names in a hidden actor but that didn't make a difference.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Best Answers

  • Two.ETwo.E Posts: 599
    Accepted Answer

    Have you tried putting that exact rule into a loop behaviours (not a loop over table).

    Just replace the when touch is pressed to when Row is less than the number of images you have.

    If I recall, that worked for me.

    Best,

  • SocksSocks London, UK.Posts: 12,822
    edited September 2017 Accepted Answer

    @tatiang said:
    I'll try that. I put it in an every 0.1 seconds Timer and it worked so my next step is to lower the Timer duration and/or try a Loop. Thanks!

    An old trick I would often use was to throw all the images into an animation behaviour (placed in the scene so it played/loaded when the scene was loaded) - the images need not be the same size (as would be the case in the normal use of an animation behaviour), just drag all your images into the animation behaviour's window set at 30fps and then place the actor with the animation behaviour off-scene/out-of-sight somewhere, or make it's size x=0, y=0 . . .

    @tatiang said:
    Edit: A loop didn't work but setting the timer to 0.05 seconds did the trick.

    In theory 0.0333333 . . . should be the maximum speed.

Answers

  • Two.ETwo.E Member Posts: 599
    edited September 2017

    How were you looping over them?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2017

    @Two.E I was hoping that simply changing an actor's self.Image to each picture in succession would help.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Interestingly, when I manually change the value of self.Image as follows, it does reduce the delay to almost nothing:

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2017

    I'll try that. I put it in an every 0.1 seconds Timer and it worked so my next step is to lower the Timer duration and/or try a Loop. Thanks!

    Edit: A loop didn't work but setting the timer to 0.05 seconds did the trick.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Another thing that removed the loading delays was changing the dpi on all image files from 300 to 72 or scaling the sizes down by about 50%.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited September 2017

    @tatiang said:
    Another thing that removed the loading delays was changing the dpi on all image files from 300 to 72 or scaling the sizes down by about 50%.

    This doesn't sound right, changing an image's ppi will have no effect on the file size (which would effect loading times), I suspect you are actually changing the image's resolution instead ?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Hmm... I plead ignorance. What I did was to run it through Photoshop's Image Size... and change the Resolution from 299.999 to 72. But I just checked and it does indeed change the pixel dimensions when I do that.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    Hmm... I plead ignorance. What I did was to run it through Photoshop's Image Size... and change the Resolution from 299.999 to 72. But I just checked and it does indeed change the pixel dimensions when I do that.

    Then you must have 'resize image' checked in Photoshop's Image Size window, which means you are changing the image's resolution and not simply changing the ppi.

    If you just want to change the ppi then you should uncheck 'resize image' or change the measurement to pixels or percent (or anything that doesn't have an actual size), but - of course - this will have no effect on the image's memory footprint / loading times !

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Socks said:
    An old trick I would often use was to throw all the images into an animation behaviour (placed in the scene so it played/loaded when the scene was loaded) - the images need not be the same size (as would be the case in the normal use of an animation behaviour), just drag all your images into the animation behaviour's window set at 30fps and then place the actor with the animation behaviour off-scene/out-of-sight somewhere, or make it's size x=0, y=0 . . .

    That's even better. Thanks!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:

    @Socks said:
    An old trick I would often use was to throw all the images into an animation behaviour (placed in the scene so it played/loaded when the scene was loaded) - the images need not be the same size (as would be the case in the normal use of an animation behaviour), just drag all your images into the animation behaviour's window set at 30fps and then place the actor with the animation behaviour off-scene/out-of-sight somewhere, or make it's size x=0, y=0 . . .

    That's even better. Thanks!

    You can also spread the images across several actors (with animation behaviours) if you need faster (than 30fps) loading.

  • Two.ETwo.E Member Posts: 599
    edited September 2017

    Just curious, have you tried just adding all the images into an actor as separate change image behaviours?
    I know with change attribute behaviours, they will activate in order within the same code cycle. I did over 200 behaviours each changing an attribute to +1, and the results were instant. I know there is a big difference between an attribute value and an image.

    Just curious, I will do a test some time this week to see, because if having multiple animation behaviours work, then a change image isn't that different.

    Best

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2017

    @Socks said:

    @tatiang said:

    @Socks said:
    An old trick I would often use was to throw all the images into an animation behaviour (placed in the scene so it played/loaded when the scene was loaded) - the images need not be the same size (as would be the case in the normal use of an animation behaviour), just drag all your images into the animation behaviour's window set at 30fps and then place the actor with the animation behaviour off-scene/out-of-sight somewhere, or make it's size x=0, y=0 . . .

    That's even better. Thanks!

    You can also spread the images across several actors (with animation behaviours) if you need faster (than 30fps) loading.

    So I did this and though it worked great, it caused GS Viewer on my iPhone to time out ("Device Disconnected"). I'm still looking for a perfect solution and may try @Two.E's suggestion.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.