Force refresh

0 favourites
  • 7 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • Hello,

    for reasons that I do not understand, both the inject and the loadfromURL plugin do not work on the iPad until something makes sprite refresh.

    To clarify:

    1) Creating a non-transparent sprite bigger than the inject/load sprite on top of it then destroying it triggers the loading/injecting

    2) Touching the sprite several time after 2-3 seconds loads/injects the new image

    This leads me to think that the problem lies in the refreshing of the canvas but executing this command:

    this.runtime.redraw = true;

    doesn't change anything, do you guys can point me in the right direction?

    Thank you

  • That line is the correct way to make the canvas redraw. The whole canvas will be repainted the next tick if you set redraw to true like that.

    Perhaps it doesn't work because the browser takes longer than one tick to load images. Most browsers work asynchronously these days so changing an image is actually just a request to begin loading the new image, which is finished possibly some time later. To really fix it, make sure the image's loaded event also sets the redraw flag.

  • Ashley

    Apparently that is not the problem, even a blinking object on top doesn't work, it's a problem here:

    this.imageObj.onload = (function (self) {

    this never fires, not until i keep on touching the screen (not one not two,but two/three in rapid sequence) do you have any idea on why this happens? Apparently only on iPad this happens.

    Thank you

  • No idea, it may be a bug in Safari on iOS that it doesn't fire onload events properly. Sorry, I don't know for sure any better.

  • Ashley after testing it looks like a bug of the simulator but I'm not completely sure.

  • Does it work when you move the sprite with two actions to another place and then back? Should force two redraws - I suppose.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • FYI the 'Set web font' feature of Text doesn't have a true 'loaded' event, and can take a few seconds to load. So for that I just forced refreshes on a timer: every 100 ms for the next 1 second (in case it loads quickly), then every 1 second for the next 5 seconds after that (so if it does load in the next 5s it should update for it). If all else fails, that might work for you too.

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