标题:小妹初来乍到,向各路高手请教!
只看楼主
我不会做题
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-8-20
 问题点数:0 回复次数:4 
小妹初来乍到,向各路高手请教!
谢谢各位大神
   
题干
    参考目标效果完成制作
    添加帧频函数:animate
    设置 bullet 向上移动(30 像素/帧)
    设置 bulletLeft 向上移动(30 像素/帧)
    设置 bulletRight 向上移动(30 像素/帧);
    当bullet.y<-50时
    设置bullet y:plane.y-50、bullet x: plane.x、
    设置bulletLeft y:plane.y、bulletLeft x:plane.x-100、
    设置bulletRight y:plane.y、 bulletRight x:plane.x+100;

小妹不知问题在哪里
var app = new PIXI.Application(500,600);
document.body.appendChild(app.view);

var bg = new PIXI.Sprite.fromImage("res/plane/bg/img_bg_level_3.jpg");
app.stage.addChild(bg);

var bullet = new PIXI.Sprite.fromImage("res/plane/bullet/img_bullet_14.png");
bullet.anchor.set(0.5,0.5);
app.stage.addChild(bullet);

var bulletLeft = new PIXI.Sprite.fromImage("res/plane/bullet/img_bullet_13.png");
bulletLeft.anchor.set(0.5,0.5);
app.stage.addChild(bulletLeft);

var bulletRight = new PIXI.Sprite.fromImage("res/plane/bullet/img_bullet_13.png");
bulletRight.anchor.set(0.5,0.5);
app.stage.addChild(bulletRight);

var plane = new PIXI.Sprite.fromImage("res/plane_blue_01.png");
plane.anchor.set(0.5,0.5);
plane.x = 250;
plane.y = 500;
app.stage.addChild(plane);

var planeLeft = new PIXI.Sprite.fromImage("res/plane/liaoji_02_11.png");
planeLeft.anchor.set(0.5,0.5);
planeLeft.x = -100;
planeLeft.y = 50;
plane.addChild(planeLeft);

var planeRight = new PIXI.Sprite.fromImage("res/plane/liaoji_02_11.png");
planeRight.anchor.set(0.5,0.5);
planeRight.x = 100;
planeRight.y = 50;
plane.addChild(planeRight);

bg.interactive = true;
bg.on("mousemove",movePlane);
function movePlane(event){
    var pos = event.data.getLocalPosition(app.stage);
    plane.x = pos.x;
    plane.y = pos.y;
}

bullet.interactive = true;
bullet.on("mousemove",animate);
function animate(event){
    var pos = event.data.getLocalPosition(app.stage);
    bullet.anchor.set(0.5,0.5);
    bullet.x = pos.x;
    bullet.y = pos.y;
    app.ticker.add(animate);
function animate(){
    bullet.y -= 30;
    if(bullet.y<-50){
        bullet.y = plane.y-50
        bullet.x = plane.x
    }
}

}
bulletLeft.interactive = true;
bulletLeft.on("mousemove",animate1);
function animate1(event){
    var pos = event.data.getLocalPosition(app.stage);
    bulletLeft.anchor.set(0.5,0.5);
    bulletLeft.x = pos.x;
    bulletLeft.y = pos.y;
    app.ticker.add(animate);
function animate(){
    bulletLeft.y -= 30;
    if(bulletLeft.y<-50){
        bulletLeft.y = plane.y
        bulletLeft.x = plane.x-100
    }
}

}
bulletRight.interactive = true;
bulletRight.on("mousemove",animate2);
function animate2(event){
    var pos = event.data.getLocalPosition(app.stage);
    bulletRight.anchor.set(0.5,0.5);
    bulletRight.x = pos.x;
    bulletRight.y = pos.y;
    app.ticker.add(animate);
function animate(){
    bulletRight.y -= 30;
    if(bulletRight.y<-50){
        bulletRight.y = plane.y
        bulletRight.x = plane.x+100
    }
}

}
















搜索更多相关主题的帖子: app new set event var 
2020-08-20 13:57
HZYCR
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2017-2-7
得分:0 
你可以尝试发在js板块问一下
2020-10-22 15:56
rh2020
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2020-10-27
得分:0 
我才是新手,我完全看不明白
2020-10-27 22:02
Hacker_Lin
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-8-24
得分:0 
为什么我在java板块看见js代码
2020-11-02 17:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-502916-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044020 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved