Confused: For Each

1 favourites
  • You can make it even cleaner - one action:

    Set size to (Self.Width+1, Self.Height+1)

    As I explained before, since my object is not in 1:1 Ratio, when using the width and height the scalling is twisting into a weird shape unlike the Scale option. :)

  • You can make it even cleaner - one action:

    Set size to (Self.Width+1, Self.Height+1)

    Hi, no, he can't.. as it doesn't consider the aspect ratio.

  • Ah, I misread - you could try something like this?

  • Since I'm using the DRAG & DROP behavior, after I have multiple instances on the screen.

    Is there a way to SELECT ALL and drag them together instead one after one?

    I don't think there is a built-in action for such basic thing, but maybe I missed it... ?

    Thanks ahead!

  • Since I'm using the DRAG & DROP behavior, after I have multiple instances on the screen.

    Is there a way to SELECT ALL and drag them together instead one after one?

    I don't think there is a built-in action for such basic thing, but maybe I missed it... ?

    Thanks ahead!

    Can you upload a picture or gif showing the objects?

  • Actually I'm still drawing them but I don't think it matters what they look like since it's just rocks in different sizes and shapes after all.

    The drag is based on a sprite anyway so the shape won't matter as long as I can somehow select the sprites TOGETHER instead dragging one by one... which is really primitive and useless.

    If it helps the screen resolution of the layout I use is Full HD 1920x1080 so I can put many rocks around, move them around as I wish but again... one by one.

  • he had tried that earlier but it wasn't scaling evenly...

    to make it scale evenly without using an instance variable you can do this:

    EDIT: I guess I should have refreshed the screen, but the code above should work fine...

  • I think part of the issue here is a misunderstanding of "picking". Whenever you refer to an object like "Sprite3" you are actually says "all instances of Sprite3 that are currently picked". By default everything is picked, which is why with your first version you were moving everything. Some conditions apply a filter to what is picked. For instance "on object Sprite3 is clicked" will only pick the instance that has been clicked. Similarly if you create a new instance that singular instance is picked.

    Your "Cursor is over Sprite" condition is filtering the picked instances down to only instances that are under the cursor. There is a condition in system "Pick all OBJECT_NAME" which allows you to make all instances of Sprite to be picked. Most actions will modify all the picked instances of the object you pass in. Whenever you use an expression like "sprite.x" it will return the value for the first picked instance.

  • Thank you so much for the detailed explanation Nepeo!

    Since I'm not a programmer there are many things that are still not very easy for me to accomplish, my thinking is very logical, but anyway the "Pick All" option sound interesting, maybe even a solution to drag all the instances on the screen?

    I did try some tests now, but of course nothing worked and it was ignored it since I'm not really sure what I'm doing, reading the documents isn't visual enough for me to learn such things also as you probably noticed English isn't my native language.

    I also have another issue when the mouse is over 2 or more objects, when I press the "DEL" key it deletes ALL the instances behind (Z-Order related)

    They are all in the same layer, but is it possible to make only if the MOUSE OVER the most TOP Layer instance to be deleted?

    Thanks ahead! :)

    EDIT:

    Thanks to your explanation I made the TOP LAYER picked to work:

    Now I can manipulate the top instance only which is great!

    Can you please help with the MULTIPLE Drag all the instances at the same time?

    This is a bit tricky for me to solve.

  • you can add another condition to mouse over rock, and choose "Pick Top/Bottom" (it is way down at the bottom of the add condition window).

    I made a quick test to select and move several objects at the same time...

    it is not nearly complete, but shows one approach - but if you are not a programmer, then it will be tricky to make it fully functional. If I have time I might work on it some more in the next day or two...

    https://www.rieperts.com/games/forum/rocks.c3p

  • you can add another condition to mouse over rock, and choose "Pick Top/Bottom" (it is way down at the bottom of the add condition window).

    I made a quick test to select and move several objects at the same time...

    it is not nearly complete, but shows one approach - but if you are not a programmer, then it will be tricky to make it fully functional. If I have time I might work on it some more in the next day or two...

    https://www.rieperts.com/games/forum/rocks.c3p

    Yes this is what I did on the edit on my early post, thanks AllanR! :)

    The other issue I'm scratching my head is the DRAG ALL... or if I could "PAN" around all the instances on the layout to move them as I wish while dragging that's another great option!

    Any ideas? suggestions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • there is no easy way to Drag All. If you use the Drag and Drop behaviour, you would have to have a system to select all the ones you want, and then on Drag Start, pin all those objects to the one being dragged. Then unpin them on Drop. (which is what my quick example above sort of does, but there are plenty of issues that would need to be fixed).

    the other option (which I would probably do) is not use the behaviour and make your own manual drag and drop system... which I have done a couple times, but not quite for what you are doing...

  • Being a programmer is just a title. I think most people use the term for a "Professional programmer" ( someone who's main source of income is creating programs ). However, many programmers make a habit of writing and releasing software for free. So in a way you wouldn't call them "professional", but they are arguably very skilled at programming. While you may not spend your days writing source code, what you are doing by creating event sheets is programming your game. So you are in fact acting as a "game programmer" or "game developer". Don't let the term "programming" seem scary or hard, some types of programming are easier or harder. The rest is just practice.

    I'm not sure why "pick all" isn't working in your project, it might be down to the order of your conditions? The filters are applied in order, so it might be that other filters are being applied after your "pick all". It can be hard to visualise which instances are picked at any one point, but as you've found the "pick top instance" condition I think with some experimentation you can probably figure out how the rest work. It's one of the most powerful tricks of the event sheets in my opinion, so it's something worth figuring out!

  • it isn't that pick all isn't working...

    he wants to place a number of objects in his layout, and then have the ability to select a bunch of them and drag them as a group. The drag and drop behaviour will automatically pick the top object and just move that one instance.

    so he needs a expand the functionality using the pin behaviour or making his own custom drag and drop routines...

  • well, curiosity got the better of me...

    here is a C2 project that can select multiple objects and drag them around...

    it uses my standard multi-touch routines, so it works with mouse or touch. (but I didn't add any logic to prevent you from using a second touch to mess with your selection/dragging)

    you can use CTRL to add or remove objects from the selection... seems pretty bullet-proof, and works the way I would expect.

    https://www.rieperts.com/games/forum/rocks.capx

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