MCPcopy Create free account
hub / github.com/eva-engine/eva.js / createTransitionDemo

Function createTransitionDemo

examples/src/canvas.ts:449–603  ·  view source on GitHub ↗
(game: Game)

Source from the content-addressed store, hash-verified

447}
448
449function createTransitionDemo(game: Game) {
450 const sectionLabel = new GameObject('transition-label', {
451 position: { x: 30, y: 1570 },
452 });
453 sectionLabel.addComponent(
454 new Text({
455 text: '▎Transition + Event 动画与交互',
456 style: { fontSize: 28, fill: ['#e94560'], fontFamily: 'Arial', fontWeight: 'bold' },
457 }),
458 );
459 game.scene.addChild(sectionLabel);
460
461 const hint = new GameObject('tap-hint', {
462 position: { x: 50, y: 1630 },
463 });
464 hint.addComponent(
465 new Text({
466 text: '点击下方的爱心试试 👇',
467 style: { fontSize: 22, fill: ['#aaaacc'], fontFamily: 'Arial' },
468 }),
469 );
470 game.scene.addChild(hint);
471
472 const heartBtn = new GameObject('heart-btn', {
473 size: { width: 150, height: 150 },
474 position: { x: 300, y: 1750 },
475 origin: { x: 0.5, y: 0.5 },
476 anchor: { x: 0.5, y: 0.5 },
477 });
478 heartBtn.addComponent(new Img({ resource: 'heart' }));
479
480 const transition = heartBtn.addComponent(new Transition());
481 transition.group = {
482 bounce: [
483 {
484 name: 'scale.x',
485 component: heartBtn.transform,
486 values: [
487 { time: 0, value: 1, tween: 'ease-out' },
488 { time: 150, value: 1.4, tween: 'ease-in' },
489 { time: 300, value: 1 },
490 ],
491 },
492 {
493 name: 'scale.y',
494 component: heartBtn.transform,
495 values: [
496 { time: 0, value: 1, tween: 'ease-out' },
497 { time: 150, value: 1.4, tween: 'ease-in' },
498 { time: 300, value: 1 },
499 ],
500 },
501 ],
502 rotate: [
503 {
504 name: 'rotation',
505 component: heartBtn.transform,
506 values: [

Callers 1

initFunction · 0.85

Calls 4

addComponentMethod · 0.95
addChildMethod · 0.45
onMethod · 0.45
playMethod · 0.45

Tested by

no test coverage detected