How do I change the image of a sprite object on creation

0 favourites
  • 10 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi,

    I am trying to create new sprite objects just off to the side of the layout. They travel across the layout to exit on the other side. But as I want a stream of sprite objects, once each new object gets to a point inside the layout a new one is created off screen which then travels across to trigger the creation of another and so on. As I need each object to inherit a different image file's size and colours, I need to access the new objects unique id and give it a new image. The problem is I don't know how to do that.

    Can I get some help please?

    Here's the code so far

    https://www.moxtra.com/v/CAEqBW15NmluehdCVXdEQmtNOXBYMDhUTm1hNjRnYUtEMIABEZADFA

  • Changing the image of a sprite would be as simple as attaching an action to set frame or animation..

    If you want to create a sprite with the same animation you could try something simple as this

    sprite on destroyed

    (local variable text)

    set local variable text to :sprite.animation

    system create object sprite

    sprite set animation: local variable text

    Example

  • Hi and thanks for the reply LittleStain,

    I would do it this way only I need the image files to be loaded as generic items. Say for example I just wanted the file names to remain the same always but not the images. So any image can be called 001 and all I need do is load new images into my file folder without having to open the project up in C2. Though I will look into something similar to your example.

    Thanks for your help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm sorry, but I don't understand what you are trying to do..

    Maybe "load image from url" is your aim?

  • Hi,

    I am already loading an image from an URL. I need to load a different image for each consecutive create object instance. I am wanting a steady stream of images flowing across the screen with a different image each create object occurrence.

    Cheers

  • if you have image "1.png"

    or

    "something"&PNG&".png" .........something1.png

  • Do so decided, is this what you wanted?

  • Thanks korbaach,

    I'll test this but I am spawning/creating a new instance of the intial sprite. I need to have a different image loading on each instance.

    I tried doing this by using the UID but it just changes the lot of them to the next image rather than giving me the sprite requested for the separate sprites.

    https://www.moxtra.com/v/CAEqBXFmOXR5ehdCVXdEQmtNOXBYMDhUTm1hNjRnYUtEMIABQpADFA

    Cheers all

  • I need to have a different image loading on each instance.

    I tried doing this by using the UID but it just changes the lot of them to the next image rather than giving me the sprite requested for the separate sprites.

    The only way to do that... is to use diffrent frames

  • Thanks Korbaach,

    Now that makes perfect sense.

    Cheers

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