var bg; bg = game.add.graphics(0, 0); bg.beginFill(0xCCEEFF, 1); bg.drawRect(0, 0, game.world.width, game.world.height); bg.endFill();
How to bg fill in the color and put the image?
var bg; bg = game.add.graphics(0, 0); bg.beginFill(0xCCEEFF, 1); bg.drawRect(0, 0, game.world.width, game.world.height); bg.endFill();
How to bg fill in the color and put the image?
The spider sense tells me that you are using the Phaser framework. If you read the documentation a little and see examples , it becomes clear that drawing images in the Phaser looks something like this:
game.load.image("some_image", "Graphics/some_image.png"); // ΠΏΠΎΠ΄Π³ΡΡΠΆΠ°Π΅ΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ var my_image = game.add.sprite(0, 0, "some_image"); // ΡΠΎΠ·Π΄Π°ΡΠΌ ΡΠΏΡΠ°ΠΉΡ ΠΈΠ· Π·Π°Π³ΡΡΠΆΠ΅Π½Π½ΠΎΠΉ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ, ΠΎΡΡΠΈΡΠΎΠ²ΡΠ²Π°Π΅ΠΌ Π΅Π³ΠΎ Π² ΠΏΠΎΠ·ΠΈΡΠΈΠΈ 0, 0 my_image.scale.setTo(2, 2); // ΠΌΠ°ΡΡΡΠ°Π±ΠΈΡΡΠ΅ΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ; Π΄Π»Ρ ΠΏΡΠΈΠΌΠ΅ΡΠ° Ρ ΡΠ²Π΅Π»ΠΈΡΠΈΠ» Π΅Ρ Π² 2 ΡΠ°Π·Π°, Π½ΠΎ Π²Ρ Π΄ΠΎΠ»ΠΆΠ½Ρ Π±ΡΠ΄Π΅ΡΠ΅ ΡΠ°ΡΡΠΈΡΠ°ΡΡ ΡΠ²Π΅Π»ΠΈΡΠ΅Π½ΠΈΠ΅ ΠΈΡΡ
ΠΎΠ΄Ρ ΠΈΠ· ΡΠΎΠΎΡΠ½ΠΎΡΠ΅Π½ΠΈΡ ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ² ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΈ ΡΠΊΡΠ°Π½Π°
Source: https://ru.stackoverflow.com/questions/300093/
All Articles