Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Я новичок помогите. (https://javascript.ru/forum/misc/82050-ya-novichok-pomogite.html)

kargabob 06.03.2021 16:26

Я новичок помогите.
 
Вообщем дело в том что крашит из за строчки гравитации.
Помогите пожалуйста.Ошибка - Cannot read property 'gravity' of null
P.S: Ничего по тебе не нашел.
Спасибо!
// You can write more code here

/* START OF COMPILED CODE */

class Scene1 extends Phaser.Scene {
	
	constructor() {
	
		super("Scene1");
		
	}
	
	_create() {
	
		var money = this.add.image(356.5754, 392.0, "textures", "\u2014Pngtree\u2014vector dollar icon_4183947");
		money.setScale(0.1, 0.1);
		
		var pers = this.add.image(204.0, 362.0, "textures", "character_zombie_run1");
		
		var meto = this.add.image(280.33298, 53.29235, "textures", "platformPack_tile004");
		
		this.fPers = pers;
		this.fBlock = money;
		this.fMeto = meto;
		
	}
	
	
	/* START-USER-CODE */
	
	create() {
		this._create();
		this.cursors = this.input.keyboard.createCursorKeys();
		this.physics.add.existing(this.fPers);
		this.physics.add.existing(this.fBlock);
		this.physics.add.overlap(this.fPers, this.fBlock, this.hit, null, this);
		this.createScore();
		this.scoreText = this.add.text(16, 16, 'score: 0', {fontSize: "32px", fill: "#000"});
	}
	
	createScore() {
		this.score = 0-1;
		var scoreText;
		}
	
	hit() {
		var p = 0;
		this.fBlock.x = Phaser.Math.Between(100, 600);
		this.fBlock.y = Phaser.Math.Between(100, 450);
		var simplex = 280.33298;
		this.score += 1;
		this.scoreText.setText('score: ' + this.score);
		this.fMeto.x = Phaser.Math.Between(100,600);
		this.fMeto.body.gravity.y = 300;
		player.body.collideWorldBounds = true;
		}

	
	update() {
		if (this.cursors.down.isDown) {
			this.fPers.y += 3;
		}else if(this.cursors.up.isDown) {
			this.fPers.y -= 3;
		}else if(this.cursors.left.isDown) {
			this.fPers.x -= 3;
		}else if(this.cursors.right.isDown) {
			this.fPers.x += 3;
		}
	}

	
	
	/* END-USER-CODE */
}

/* END OF COMPILED CODE */

// You can write more code here

рони 06.03.2021 16:36

kargabob,
строка 54 в this.fMeto.body нет метода gravity

kargabob 06.03.2021 16:54

А как приделать к нему гравитацию?

рони 06.03.2021 17:08

kargabob,
искать специалистов по Phaser или гуглить.

рони 06.03.2021 17:09

kargabob,
https://www.phaser.io/examples/v2/ar...hysics/gravity

kargabob 06.03.2021 19:18

Спасибо!Удачи вам
 
Спасибо вам обоим!Вы профессионалы.Просто лучшие.Карьеру вам в Google!!!!!
P.S:Удачи!!!
:help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help::dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance:
:help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help::dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance:
:help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help: :help::dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance: :dance:


Часовой пояс GMT +3, время: 02:54.