phaser3-nineslice icon indicating copy to clipboard operation
phaser3-nineslice copied to clipboard

Bug: Types file doesn't specify alternative inputs.

Open shelbykauth opened this issue 3 years ago • 1 comments

I was trying to use the key+frame key definition, as well as the array definition of offset and safe boundaries. But it won't let me.

I'm specifically using Typescript with strict mode. I can't cast an object as a string. And I can't compile while passing in an object.

In the summary of your readme, you have:

Valid arguments to .add.nineslice and .make.nineslice are:

Arguments =
  | (NineSliceConfig, PositionConfig)
  | (x: number,
     y: number,
     w: number,
     h: number,
     source: FrameSelection,
     corner: OffsetConfig,
     safeArea: OffsetConfig | null)

FrameSelection =
  | key: string
  | {
      key: string,
      frame: number | string,
    }

OffsetConfig =
  | number
  | [topRightBottomLeft: number]
  | [topBottom: number, rightLeft: number],
  | [top: number, rightLeft: number, bottom: number],
  | [top: number, right: number, bottom: number, left: number]

But nineslice.d.ts has: nineslice(x: number, y: number, width: number, height: number, key: string, offset: number, safeArea?: number): Phaser.GameObjects.RenderTexture;

All of the last 3 parameters cause errors such as this. image image

shelbykauth avatar Mar 07 '21 00:03 shelbykauth

use { key: 'button_default', frame: i } as any, before this gets resolved.

You could use NineSlice (not '.add' or '.make', but 'new NineSlice'), which atm does support TS, like this: const cornerConfig: CornerConfig = { width: 18 }; const nineSliceConfig: NineSliceConfig = { sourceKey: 'button_default', sourceFrame: frameName, sourceLayout: cornerConfig }; const positionConfig: PositionConfig = { x:0, y:0, width:400, height:400 }; const slice = new NineSlice( this.scene, nineSliceConfig, positionConfig); this.add(slice); ... where your frameName is the frame name of frame at index 'i', HOWEVER there are other issues with this package atm (seems creator is looking for a new parent as of 7d ago), and when i use the above, i get: "Uncaught Error: Framebuffer status: Incomplete Attachment"

But hey, you can still use the first option, it does work for me.

michalfialadev avatar Jan 05 '22 16:01 michalfialadev