小编Toe*_*ash的帖子

JS游戏 - 随机拍摄

我正在开发基于HTML5 canvas/Javascript的游戏.这是一个战斗机游戏,在我通过特定分数后,我的主要老板会产生.一切都像我想的那样,但是,我不怎么做老板射击.我的喷气机发射一颗子弹,但我的想法是让老板随意射击.同时至少3发子弹,方向不同.我没有使用jQuery只是普通的JS.Boss从边界移动到另一个边界,但它没有射击,所以我可能需要一些帮助.有任何想法吗 ?

在此输入图像描述

红线是我拍摄的主意.我有能力检查子弹/喷气机碰撞.

一些代码的老板(垂直)射击.

function BossBullet() {
    this.srcX = 1304;
    this.srcY = 0;
    this.drawX = 500;
    this.drawY = 0;
    this.width = 4;
    this.height = 16;
}

BossBullet.prototype.akt = function(X,Y) {

    this.noseX=X;
    this.noseY=Y;
};

BossBullet.prototype.draw = function() {
    ctxBullet.clearRect(0, 0, gameWidth, gameHeight);
    this.drawY += 10;

    ctxBullet.drawImage(imgSprite, this.srcX, this.srcY, this.width, this.height, this.drawX, this.drawY, this.width, this.height);
   //strela[hudba].play();
    if (this.drawY > 700) {
        this.drawY= this.noseY;
        this.drawX= this.noseX;

    }
};
Run Code Online (Sandbox Code Playgroud)

这就是它的样子.它从老板鼻子发射单个子弹并向下直到它达到其Y值0并重新生成.

在此输入图像描述

我试图添加到this.drawY += 10;this.drawX += 1;不过这样一来它没有在所有移动.任何想法如何改变子弹的目录?

javascript canvas

8
推荐指数
2
解决办法
2731
查看次数

Firebase:从signInWithEmailAndPassword 返回捕获的错误

我正在将 firebase 与电子邮件+密码身份验证提供商一起使用。正确的凭据情况可以按预期工作。我的问题是,如果凭据错误,则会捕获错误,但我不知道如何传回此信息。

我正在将 redux store 的调度与mapDispatchToProps.

const mapDispatchToProps = (dispatch) => ({
  startLogin: (email, password) => dispatch(startLogin(email, password))
});
Run Code Online (Sandbox Code Playgroud)

然后,我只需使用组件中的凭据调用此操作,如果返回未定义(引发错误),我会设置错误。

startLogin(email, password).then((data) => {
  if (!data) {
    setErrors({ login: 'Wrong credentials' });
  }
});
Run Code Online (Sandbox Code Playgroud)

我的动作是这样的。

export const startLogin = (email, password) => {
  return firebase.auth().signInWithEmailAndPassword(email, password).catch((err) => {
    console.log(err);
  });
};
Run Code Online (Sandbox Code Playgroud)

这是可行的,但控制台显示 POST 400 错误,我想避免这种情况。

在此输入图像描述

firebase reactjs firebase-authentication

5
推荐指数
1
解决办法
1168
查看次数