RexUI Interactions And Effects
Use this skill when RexUI UI objects need input behavior, gesture recognition, screen anchoring, event isolation, or small visual effects.
Use This First
| Need |
Prefer |
| Button-like click on one object |
this.rexUI.add.click(gameObject, config) |
| Close a popup by clicking outside it |
this.rexUI.add.clickOutside(panel, config) |
| Tap, double-tap, long press, swipe, pan |
tap, press, swipe, pan |
| Two-finger scale or rotate |
pinch and rotate |
| Make an object draggable |
this.rexUI.add.drag(gameObject, config) or this.rexUI.requestDrag(gameObject) |
| Stop gameplay input under a UI overlay |
this.rexUI.add.touchEventStop(gameObject, config) |
| Keep a panel aligned to viewport resize |
anchor config or this.rexUI.add.anchor(gameObject, config) |
| Toggle fullscreen from an image/button |
this.rexUI.add.fullscreenButton(gameObject, config) |
| Animate opacity or position |
this.rexUI.fadeIn, fadeOutDestroy, easeMoveTo, easeMoveFrom |
| Card flip, impact feedback, temporary skew/perspective |
flip, shake, skew, perspective, perspectiveCard |
Core Rules
- Behaviors attach to existing game objects; create and lay out the target first.
- Most behavior factories are under
this.rexUI.add.*, but fade, easeMove, requestDrag, and isInTouching are methods on this.rexUI itself.
- Use npm import paths such as
phaser4-rex-plugins/templates/ui/ui-plugin.js in generated app code. Source paths in these notes point to this repository only.
- For layout objects, call
.layout() before anchoring, hit testing, clickOutside, flip, skew, perspective, or animation that depends on final bounds.
- For pointer-heavy scenes, add extra pointers with
this.input.addPointer(count). Pinch and rotate need at least 2 pointers.
- Avoid attaching competing gestures to the same object without a clear priority. Scrollable components already use pointer gestures internally.
- Store behavior instances when they must be enabled, disabled, reused, or cancelled later.
Factory And Helper Boundaries
Use this.rexUI.add.*:
const click = this.rexUI.add.click(button, { mode: 'pointerup' });
const drag = this.rexUI.add.drag(panel, { axis: 'both' });
const stop = this.rexUI.add.touchEventStop(panel, { stopAllLevels: true });
Use this.rexUI.*:
this.rexUI.fadeIn(panel, 200);
this.rexUI.fadeOutDestroy(panel, 200, true);
this.rexUI.easeMoveTo(panel, 300, '+=0', '-=80', 'Cubic');
this.rexUI.requestDrag(panel);
Many RexUI layout/widget objects inherit BaseSizer convenience methods for the common click, click-outside, touching, and bounds-check cases:
panel.onClick((click, gameObject, pointer) => submit());
panel.onClickOutside(() => closePanel());
panel.onTouching((inTouch, gameObject, pointer) => stepValue(1), undefined, { cooldown: 120 });
panel.disableClick();
panel.isPointerInBounds();
Use these methods when the target is already a RexUI sizer/widget and the handler is local to that object. Use explicit this.rexUI.add.click, clickOutside, or inTouching behavior objects when code needs to store the behavior instance, attach to a plain Phaser game object, or share/reconfigure the behavior independently.
Gotcha: fullscreenButton is registered as this.rexUI.add.fullscreenButton(...). Do not use the capitalized type name as the factory call.
Gotcha: in the RexUI factory source, pinch and rotate are scene-level gesture recognizers. Prefer this.rexUI.add.pinch(config) and this.rexUI.add.rotate(config), then apply the returned gesture values to the object you want to transform.
References
- For gesture selection, events, and reduced input recipes, read references/gesture-behaviors.md.
- For fade, easeMove, flip, shake, skew, and perspective recipes, read references/effect-recipes.md.
- For responsive anchoring, fullscreen buttons, touch event blocking, and layer/input notes, read references/anchor-fullscreen.md.
Source Map
templates/ui/ui-plugin.js: RexUI factory registration and helper methods.
templates/ui/ui-plugin.d.ts: public factory names and helper method names.
templates/ui/basesizer/BaseSizer.d.ts: inherited click, click-outside, touching, pointer bounds, and child-target convenience methods.
templates/ui/click, clickoutside, tap, press, swipe, pan, pinch, rotate, drag, intouching: input behavior wrappers.
templates/ui/anchor, fullscreenbutton, toucheventstop, layermanager: viewport, fullscreen, event isolation, and layer helpers.
templates/ui/flip, shake, skew, perspective, perspectivecard, fade, easemove: visual effects and motion helpers.
1---2name: rexui-interactions-and-effects3description: Use when building Phaser RexUI interactions, gesture behaviors, anchors, fullscreen buttons, touch event blocking, drag/click/tap/press/swipe/pan/pinch/rotate handling, or UI effects such as flip, shake, fade, easeMove, skew, and perspective via this.rexUI.add.* or this.rexUI.*.4---56# RexUI Interactions And Effects78Use this skill when RexUI UI objects need input behavior, gesture recognition, screen anchoring, event isolation, or small visual effects.910## Use This First1112| Need | Prefer |13| --- | --- |14| Button-like click on one object | `this.rexUI.add.click(gameObject, config)` |15| Close a popup by clicking outside it | `this.rexUI.add.clickOutside(panel, config)` |16| Tap, double-tap, long press, swipe, pan | `tap`, `press`, `swipe`, `pan` |17| Two-finger scale or rotate | `pinch` and `rotate` |18| Make an object draggable | `this.rexUI.add.drag(gameObject, config)` or `this.rexUI.requestDrag(gameObject)` |19| Stop gameplay input under a UI overlay | `this.rexUI.add.touchEventStop(gameObject, config)` |20| Keep a panel aligned to viewport resize | `anchor` config or `this.rexUI.add.anchor(gameObject, config)` |21| Toggle fullscreen from an image/button | `this.rexUI.add.fullscreenButton(gameObject, config)` |22| Animate opacity or position | `this.rexUI.fadeIn`, `fadeOutDestroy`, `easeMoveTo`, `easeMoveFrom` |23| Card flip, impact feedback, temporary skew/perspective | `flip`, `shake`, `skew`, `perspective`, `perspectiveCard` |2425## Core Rules2627- Behaviors attach to existing game objects; create and lay out the target first.28- Most behavior factories are under `this.rexUI.add.*`, but fade, easeMove, requestDrag, and `isInTouching` are methods on `this.rexUI` itself.29- Use npm import paths such as `phaser4-rex-plugins/templates/ui/ui-plugin.js` in generated app code. Source paths in these notes point to this repository only.30- For layout objects, call `.layout()` before anchoring, hit testing, clickOutside, flip, skew, perspective, or animation that depends on final bounds.31- For pointer-heavy scenes, add extra pointers with `this.input.addPointer(count)`. Pinch and rotate need at least 2 pointers.32- Avoid attaching competing gestures to the same object without a clear priority. Scrollable components already use pointer gestures internally.33- Store behavior instances when they must be enabled, disabled, reused, or cancelled later.3435## Factory And Helper Boundaries3637Use `this.rexUI.add.*`:3839```js40const click = this.rexUI.add.click(button, { mode: 'pointerup' });41const drag = this.rexUI.add.drag(panel, { axis: 'both' });42const stop = this.rexUI.add.touchEventStop(panel, { stopAllLevels: true });43```4445Use `this.rexUI.*`:4647```js48this.rexUI.fadeIn(panel, 200);49this.rexUI.fadeOutDestroy(panel, 200, true);50this.rexUI.easeMoveTo(panel, 300, '+=0', '-=80', 'Cubic');51this.rexUI.requestDrag(panel);52```5354Many RexUI layout/widget objects inherit `BaseSizer` convenience methods for the common click, click-outside, touching, and bounds-check cases:5556```js57panel.onClick((click, gameObject, pointer) => submit());58panel.onClickOutside(() => closePanel());59panel.onTouching((inTouch, gameObject, pointer) => stepValue(1), undefined, { cooldown: 120 });60panel.disableClick();61panel.isPointerInBounds();62```6364Use these methods when the target is already a RexUI sizer/widget and the handler is local to that object. Use explicit `this.rexUI.add.click`, `clickOutside`, or `inTouching` behavior objects when code needs to store the behavior instance, attach to a plain Phaser game object, or share/reconfigure the behavior independently.6566Gotcha: `fullscreenButton` is registered as `this.rexUI.add.fullscreenButton(...)`. Do not use the capitalized type name as the factory call.6768Gotcha: in the RexUI factory source, `pinch` and `rotate` are scene-level gesture recognizers. Prefer `this.rexUI.add.pinch(config)` and `this.rexUI.add.rotate(config)`, then apply the returned gesture values to the object you want to transform.6970## References7172- For gesture selection, events, and reduced input recipes, read [references/gesture-behaviors.md](references/gesture-behaviors.md).73- For fade, easeMove, flip, shake, skew, and perspective recipes, read [references/effect-recipes.md](references/effect-recipes.md).74- For responsive anchoring, fullscreen buttons, touch event blocking, and layer/input notes, read [references/anchor-fullscreen.md](references/anchor-fullscreen.md).7576## Source Map7778- `templates/ui/ui-plugin.js`: RexUI factory registration and helper methods.79- `templates/ui/ui-plugin.d.ts`: public factory names and helper method names.80- `templates/ui/basesizer/BaseSizer.d.ts`: inherited click, click-outside, touching, pointer bounds, and child-target convenience methods.81- `templates/ui/click`, `clickoutside`, `tap`, `press`, `swipe`, `pan`, `pinch`, `rotate`, `drag`, `intouching`: input behavior wrappers.82- `templates/ui/anchor`, `fullscreenbutton`, `toucheventstop`, `layermanager`: viewport, fullscreen, event isolation, and layer helpers.83- `templates/ui/flip`, `shake`, `skew`, `perspective`, `perspectivecard`, `fade`, `easemove`: visual effects and motion helpers.