Another picking thread

This forum is currently in read-only mode.
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Ok I have an image, and I have set up 5 image points numbered 1-5, and I want to take 5 duplicates of the same sprite and place them on the image with the 5 image points.

    Geez we really need a better way to pick from multiple instances, at least we do if you want the idiot savants like me to be able to use this thing.

    Any way this:

    System: 3 For each spot 0  ordered by spot 1 .x Ascending
    

    spotSet position to object citi 0 (image point spot 1 .Value('var'))

    spotAdd 1 to 'var'

    [/code:2m0fmwxl]

    Does not work, it places all sprites at the same image point, plus its not even getting any of the preset points, just the original "point" instead.

    Yes I know, I could simply create additional objects and do it that way, but I'm trying to optimize things as much as possible. I'm already getting "out of vram" errors as it is.

  • Give the sprite a private variable and number them 1 through 5.

  • Or use magic pink.

    Is there a better way than the way I was using?

    I thought the for each would work like a loop, and each picked by object's x, would add 1 to private variable "var", then I could use the variable to set to the points. Evidently its not even using the variable when placing the image to the points.

  • Does it work if you do:

    + For Each Spot

    -> Set spot position to Sprite.ImagePointX(LoopIndex), Sprite.ImagePointY(LoopIndex)

  • Sorry nope.

    The loops running fine, but it keeps putting everything on one spot. Initially I thought it was using the original "point", but now it seems its using the hot spot instead.

    Anyway I figured a work around, I had each sprite spawn a text with the object unique id, then I just wrote down that info, and made an event for each unique id... works fine.

    Now my next question, is there a way to get objects unique id without having to a get them at runtime?

  • Or use magic pink.

    Okay:

    http://dl.getdropbox.com/u/529356/fivepoints.cap

    No, seriously... it works. Give the sprite a variable, and number them 1 - 5. You don't need to use UID. Hell, you don't even need to make five copies of the sprite in the layout... you could Destroy On Startup and make a loop that creates five sprites and numbers their var 1 - 5.

  • Ok... thanks, but wtf?

    First I haven't found anything explaining

    "" & Sprite.Value('var')[/code:2nyqp1db].
    Ok ampersand means add to the variable, but [code:2nyqp1db]""[/code:2nyqp1db] means huh?
    Second, every time I add a private variable, it automatically creates an initial value no mater what I do.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First I haven't found anything explaining

    "" & Sprite.Value('var')[/code:26ywxdpp].
    Ok ampersand means add to the variable, but [code:26ywxdpp]""[/code:26ywxdpp] means huh?
    

    Well... image points can be referred to by name or number, yeah? And they're named 1, 2, 3, 4, and 5. So I added "" to indicate that it was a string, so as to reference the point by name. Then I put in & which is the string concatenator.

    Second, every time I add a private variable, it automatically creates an initial value no mater what I do.

    So change it in properties. Different instances of objects can have different values in their private variables in the layout.

    Or, as I mentioned before, with a loop at runtime. Either way will work.

  • Alright I get it now, thanks.

    [quote:1r76jtae]So change it in properties. Different instances of objects can have different values in their private variables in the layout.

    See I didn't know that was possible, did not know that each additional object dropped on the layout could have its own specs. Hidden feature I guess.

    Thanks again, now I've got tons to play with.

  • > So I added "" to indicate that it was a string, so as to reference the point by name.

    >

    That seems like a backwards and undocumented way of doing it... Can't you just use str()?

  • NO!

    Well I don't know, maybe. I never tried.

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