0 Favourites

Force refresh

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Does it work when you move the sprite with two actions to another place and then back? Should force two redraws - I suppose.

  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Force WebGL1
48 2,601
Ashley's avatar
Ashley Construct Team Founder
Topic
0 Favourites
Chrome refreshing
20 2,618
ghost's avatar
ghost
Topic
22 2,598
delgado's avatar
delgado