How do I dynamically imageLoad two frame into one Sprite Animation?

  • I have a sprite that is a two frame animation. But when I load in the image using "Load Image From...", it only replaces the first frame. Can someone tell me how I replace both?

  • You have to replace them one after the other. Prior to your call to "Load image from...", stop the animation and use "set animation frame" to manually select which frame you are trying to replace. Once every frame is done, you can resume the animation playback and it should be using all your newly loaded images.

    Side note : Your sprite needs to already have a two-frame animations (with placeholder images) for it to work.

  • This is what I have but no luck... Am I missing something? It does load in frame 1 and does appear - but does not animate or show frame 2.

    (And I do have filler graphics in the frames to start)

  • Without looking at it too much my first guess as where to look is where you set the animation frame. It is zero indexed, so it would 0 and 1, not 1 and 2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also, notice the stop-watch icon indicating that the action is asynchronous. After each "Load image from..." you should add a "Wait for previous action to complete".

  • Should this type of "initiation happen ON START OF LAYOUT at the very beginning? I have other set-up code and this seems to interfere with that a bit. I know thats vague, but what is the best practice in terms of loading dynamic data?

    1) At the very beginning before the local assets load and set-up?

    or

    2) After the local assets and set-up has completed?

    or other?

    Thank you for the replies - these were very helpful.

  • If that init happens once and never need to run again later, I'd personally go for a dedicated loading/transition layout.

    If it needs to be done on a layout per layout basis, I'd go for a "Start of layout" kind of mechanic like you said.

  • As a followup - does anyone know of any issues if user is not connected (when dynamically loading an image)? I just want to make sure the respective OS doesn't kick in with some type of error outside of the game. Of course I will test, but I don't have access to all (iOS, web, Android, etc) platforms and thought I would ask. I realize the local image will load, if the dynamic one is unaccessible, but just trying to keep the ux seamless. Thoughts?

  • The Browser object's "Is Online" condition may come in handy to only fetch your images if the user is actually connected to the internet.

    Not sure how robust is the "online" detection mechanism but it's worth a try.

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