modify origin point of a sprite after "load from URL"

0 favourites
  • 4 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hello there

    In my project i need to load several image in a sprite with "load from URL" action.

    work fine, so i can change images without exporting the project every time.

    -> card: Add animation json.Get("cards."& loopindex &".name")

    -> card: Set animation to json.Get("cards."& loopindex &".name")(play from beginning)

    -> card: Load image from url_img_card & json.Get("cards."& loopindex &".name") & ".png" (Resize to image size, cross-origin anonymous)

    my issue is, when create a new animation, the origin point is a (0,0) but in the project, all positions of the sprite are about center .

    for now i manually modify like this for every actions where i need to position the sprite, but not very practical

    -> card: Set position to (Self.X - (Self.width×0.5), Self.Y - (Self.height×0.5))

    is it a way to center the sprite origin point after a load from url in a new animation?

    i also try to create some animations with right names and right size and center origin point, that work but i need to add some images frequently so need to automatically add animations

  • Can you manually add some placeholder animations with empty frames, and set the desired origin point location? Then in runtime select an empty frame and load a new image into it.

    In older releases of Construct it was not possible to add frames in runtime. So if you needed to load 100 images, you had to manually add 100 frames in the animation editor.

    Another option is to use an invisible "base" sprite for each card (with the origin point in the center), and attach the card image to it using hierarchy.

  • Can you manually add some placeholder animations with empty frames, and set the desired origin point location? Then in runtime select an empty frame and load a new image into it.

    the card collection in the game is growing regularly, so I need to be able to automate the addition of images.

    I need to use animations because each card in the game has a name, and so I rename the animations thanks to the card names which allows me to be able to load the right cards when they are used.

    Another option is to use an invisible "base" sprite for each card (with the origin point in the center), and attach the card image to it using hierarchy.

    This is a good lead, I will do some tests because it could indeed resolve the placement problem by making it automatic.

    Thanks, I will try this

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • After making the changes the test is conclusive, and works perfectly.

    Thanks again dop2000 for the tip that allows me to get out of this impasse

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