MCPcopy
hub / github.com/phaserjs/phaser / create

Method create

scripts/tsgen/test/bin/game.js:36–662  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 this.load.on(Phaser.Loader.Events.PROGRESS, (value) => { });
35 }
36 create() {
37 // ---------------------------------------------------------------
38 // Game Objects - Core types
39 // ---------------------------------------------------------------
40 // Image
41 let image = this.add.image(100, 100, 'logo');
42 image.setOrigin(0.5, 0.5);
43 image.setScale(2);
44 image.setAngle(45);
45 image.setAlpha(0.8);
46 image.setDepth(10);
47 image.setPosition(200, 200);
48 image.setRotation(Math.PI / 4);
49 image.setVisible(true);
50 image.setBlendMode(Phaser.BlendModes.ADD);
51 image.setScrollFactor(1, 1);
52 image.setFlip(true, false);
53 image.setTint(0xff0000);
54 image.setTexture('logo');
55 image.setDisplaySize(64, 64);
56 image.setSize(64, 64);
57 image.setInteractive();
58 image.setName('myImage');
59 image.setData('score', 100);
60 image.getData('score');
61 image.setDataEnabled();
62 image.destroy();
63 // Sprite
64 let sprite = this.add.sprite(400, 300, 'cards', 'clubs3');
65 sprite.play('walk');
66 sprite.anims.pause();
67 sprite.anims.resume();
68 sprite.anims.stop();
69 // Text
70 let text = this.add.text(100, 100, 'Hello Phaser 4', {
71 fontFamily: 'Arial',
72 fontSize: '32px',
73 color: '#ffffff',
74 align: 'center',
75 wordWrap: { width: 300 },
76 padding: { x: 10, y: 10 },
77 backgroundColor: '#000000',
78 stroke: '#ff0000',
79 strokeThickness: 2,
80 shadow: { offsetX: 2, offsetY: 2, color: '#000', blur: 4, fill: true }
81 });
82 text.setText('Updated text');
83 text.setStyle({ fontSize: '48px' });
84 text.setColor('#00ff00');
85 text.setFontSize(24);
86 text.setFontFamily('Courier');
87 text.setWordWrapWidth(400);
88 text.setPadding(10, 10, 10, 10);
89 // BitmapText
90 let bitmapText = this.add.bitmapText(200, 200, 'font', 'Hello', 32);
91 bitmapText.setText('Updated');
92 bitmapText.setFontSize(48);
93 bitmapText.setLetterSpacing(2);

Callers

nothing calls this directly

Calls 15

setOriginMethod · 0.80
setScaleMethod · 0.80
setAngleMethod · 0.80
setDepthMethod · 0.80
setPositionMethod · 0.80
setRotationMethod · 0.80
setVisibleMethod · 0.80
setBlendModeMethod · 0.80
setScrollFactorMethod · 0.80
setFlipMethod · 0.80
setTintMethod · 0.80
startFollowMethod · 0.80

Tested by

no test coverage detected