GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

Duplicate instance offset before creating the instance

Open danired opened this issue 2 years ago • 2 comments

I added a offset when duplicating an instance using CTRL+Click.

For creating the instance, you have to move the cursor 25 pixels away from where you clicked first.

Example video https://user-images.githubusercontent.com/21989259/221939494-65c42c25-de66-44da-8fa6-e660e12072b6.mp4

danired avatar Feb 28 '23 17:02 danired

This is great!

Have you tested how this works with grid enabled? (check with grid size larger and smaller than the offset)

I wonder if we should use the same offset variable that is used when duplicating instances with the shortcut.

// From 4ian/GDevelop/newIDE/app/src/UI/KeyboardShortcuts/index.js

export const MOVEMENT_BIG_DELTA = 5;
import { MOVEMENT_BIG_DELTA } from '../UI/KeyboardShortcuts';

const newInstances = editor.addSerializedInstances({
      position: [0, 0],
      copyReferential: [-2 * MOVEMENT_BIG_DELTA, -2 * MOVEMENT_BIG_DELTA],
      serializedInstances: serializedSelection,
      preventSnapToGrid: true,
    });

Which ends up being 2 * 5 = 10 pixels, with the current value of that constant. What do you think?

tristanbob avatar Feb 28 '23 22:02 tristanbob

Have you tested how this works with grid enabled? (check with grid size larger and smaller than the offset)

Yes, and works fine.

I wonder if we should use the same offset variable that is used when duplicating instances with the shortcut.

// From 4ian/GDevelop/newIDE/app/src/UI/KeyboardShortcuts/index.js

export const MOVEMENT_BIG_DELTA = 5;

... Which ends up being 2 * 5 = 10 pixels, with the current value of that constant. What do you think?

I think that are different things that don't need to match. IMHO 25 pixels is OK, but maybe it can be lowered to 20 or 15.

I just lowered to 15. But I think this is a personal value and perhaps you would prefer a different value.

danired avatar Mar 01 '23 20:03 danired