Load Image from URL

0 favourites
  • 9 posts
  • I have two sprites connected together in a container. On a certain event I create sprite1 and pin sprite2 to sprite1. And on every tick I set sprite1 to move and sprite2 moves along with it. I continually create sprite1 objects and each time the proper sprite2 seems to be pinned and everything is great.

    But after this I use the Load Image from URL where the URL is determined by a subevent to update sprite2 and it seems all instances of the sprite get their image updated. I've tried putting an Opacity action in the same subevent and only the proper instance of sprite2 gets changed. Is there some issue with Load Image from URL not respecting the instance in an event?

  • the load image from url command replaces the current frame of the object so every object gets a new image, you can avoid this by giving the sprite an additional frame then just put an event like "sprite set frame to frame x" and then put the load image from url event, so the other sprites can keep the original image.

  • Can I add a frame on the fly or do I have to estimate the number of frames needed at edit time? Also these objects are getting created and destroyed constantly. You think I need some type of counter to figure out which frame to set it to?

  • Is there any place that explains this better? I'm digging through the js and I'm trying to figure out what you mean by "replaces the current frame." Seems to me each instance would have a separate current frame.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • All the instances of a sprite share the same animation images. The current frame of an instance just references which image of that sprite object is used. So when you load a image from a url it replaces the shared image.

    In other words say your sprite is named "sprite" and it has three animation frames.

    Sprite object:

    frame 1

    frame 2

    frame 3

    Next you have four instances, all which use frame 1.

    sprite instance 1 -> frame 1

    sprite instance 2 -> frame 1

    sprite instance 3 -> frame 1

    sprite instance 4 -> frame 1

    So now if you use the "load image from url" action the instance's image isn't replaced (instances only reference images), instead the "sprite" type's image is replaced.

    You can't add a frame on the fly with the sprite object. You could just set each instance to use a different frame, but yeah you do need to add them at edittime.

  • Thanks for the info. After some digging I finally figured it out as well. So at least I'm on the right track.

  • Well, I present, my procedure is from Peru and I have a problem ... In my mobile video game there is a character where you can put your mask by selecting the image of your cell phone, but there is a problem when putting Image of the URL selector file, the Image protrudes from the pixelated circle.

    How do I make the image fit in that pixelated circle?

  • Well, I present, my procedure is from Peru and I have a problem ... In my mobile video game there is a character where you can put your mask by selecting the image of your cell phone, but there is a problem when putting Image of the URL selector file, the Image protrudes from the pixelated circle.

    How do I make the image fit in that pixelated circle?

    Happy to see someone has same request as mine. Is there are a way we could make the uploaded image to fit into a circle?

  • You can resize the sprite in "On image URL loaded" event:

    Sprite set size to circle.width, circle.width
    

    Or, if you want to keep aspect ratio:

    set variable n to max(Sprite.width, Sprite.height)/circle.width
    Sprite Set size to self.width/n, self.height/n
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)