@the1studio/cocos-warning
v1.0.1
Published
Warning overlay component for Cocos Creator 3.x with pulsing animation effect
Maintainers
Readme
Cocos Warning
Warning overlay component for Cocos Creator 3.x with pulsing animation effect.
Installation
npm install @anthropic/cocos-warningSetup
Copy folder assets/ từ node_modules/@anthropic/cocos-warning/ vào project của bạn:
node_modules/@anthropic/cocos-warning/assets/
├── DangerScreen.png
└── Warning.prefabKéo Warning.prefab vào scene.
Usage
import { Warning } from '@anthropic/cocos-warning';
// Start animation
Warning.instance?.startWarningAnimation();
// Stop with fade out
Warning.instance?.stopWarningAnimation();
// Stop immediately
Warning.instance?.stopWarningAnimation(true);Change Color
import { Color } from 'cc';
Warning.instance?.setWarningColor(new Color(0, 0, 255, 255)); // BlueProperties (Editor)
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| warningColor | Color | Red | Warning overlay color |
| maxAlpha | number | 150 | Max opacity (0-255) |
| fadeDuration | number | 0.5 | Fade cycle duration (seconds) |
API
| Method | Description |
|--------|-------------|
| startWarningAnimation() | Start pulsing animation |
| stopWarningAnimation(force?) | Stop animation |
| setWarningColor(color) | Change color dynamically |
License
MIT
