0 Favourites

positioning sprites

This forum is currently in read-only mode.
  • I have a square-sprite (= background) and a few sprites (= pictures of items). Together they form a list of pictures of the items you can upgrade.

    How do I position it all effeciently (for me, as fast as possible) in the event sheet?

    For example:

    in runtime: right click will display the square, on the x/y where I point, and inside the square I want the other sprites (items) displayed.

  • I guess the answer is: making image points and matching them with the hotspot of the other sprites, I now realize.

    Is that correct?

    But you can't test this out, unless you run the game, if I'm correct.

  • You could do that.

    I would position them relatively to the background.

    Right click - background - set position to mousex, mousey

                - item - set position to background.x, background.y + 32

    You could use a loop to automate it. The only tricky part would be picking the right object, but I am sure there is a way to do that, the just set the position to "background.y + 32 * loopindex" and so on.

  • Yes, but what if you move the sprites around, on the canvas, and think: this is how I want it.

    Then how do I know how many pixels I insert at the background.x + ? and background.y + ? ?

  • dl.dropbox.com/u/1487524/Scirra/setPositionExample.cap

    Have a look at that Rogerty, is this the sort of thing you are meaning? Click and drag the background or the item to move them.

  • Steven, sorry for my late reply.

    Thanks for the cap.

    Before I ask any questions, was it clear, or does it make any difference, that the player is not supposed to change anything, only me?

    The only thing I want to do is: position sprites that overlap eachother in a way I like and keep it that way (since it will be a menu in the game).

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • For the process of laying out your menu it doesn't make a difference. Just use a method like Steven's example and note the relative values somewhere. For the game you then hardcode these offets, instead of letting the player move things around.

  • Thanks for the reply Tulamide. I think I can use Steven's method.

    I wonder: How do other people deal with this issue?

  • dl.dropbox.com/u/1487524/Scirra/setPositionMenuExample.cap

    Is this more of what you are looking for Rogerty?

  • Steven,

    Thanks a lot for the cap.

    Your 1st cap's method is what I use to find out the x/y offset and hardcode this for the menu.

    Your 2nd cap is something I can use for general purposes. Thanks again!

    About your 2nd cap: you used the function "clamp".

    I have never seen or heard of this before.

    I could I have known how to use this?

  • With offsets you will become more adept at figuring it out on the fly, placing an object, running to see if it is in the right place, adjusting etc. The debug menu also has a sprites position relative to 0,0 which might help you also. Grab the Tiledbackground texture from the cap, and place it down on your background, each square is 32x32 so you will have a good idea where you are at right away.

    Clamp is awesome, it really simplified a lot things for me. Quazi or his brother introduced clamp to me somewhere a long the way, and once you find it, you will find a lot of places to use it.

    Clamp(a, b, c)

    a is where the value changes. b is where the bottom limit of the change to value a, c is the upper limit of the change to value a.

  • Thanks for the explanation of clamp. I hope the wiki (of CC and C2) will get more extensive.

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