herbert99121 2019-4-9 23:08
係dreamweaver想完左bg3就顯示end果個圖,但唔得,有無解救方法?
var myCanvas;
var bg;
var bg2;
var bg3;
var end;
var dot;
var hitbg = false;
function setup() {
// put setup code here
myCanvas = createCanvas(1366, 768);
bg = createSprite(1366/2,768/2);
//bg.addImage(loadImage('images/platform.png'));
//bg.addImage(loadImage('images/Artboardtt.png'));
bg.addImage(loadImage('images/Artboard1.png'));
//bg.addAnimation('nomal','images/Artboard1.png', 'images/Artboard1.png');
//bg.scale = 1;
bg2 = createSprite(1366/2,768/2);
bg2.addImage(loadImage('images/Artboard2.png'));
bg2.visible = false;
bg2.position.x = 3000;
bg3 = createSprite(1366/2,768/2);
bg3.addImage(loadImage('images/Artboard3.png'));
bg3.visible = false;
bg3.position.x = 3000;
dot = createSprite(200,600);
dot.addAnimation('nomal','images/dot1.png','images/dot1.png');
dot.scale = 1;
end = createSprite(1366/2,768/2);
end.addImage(loadImage('images/End1.png'));
end.visible = false;
end.position.x = 3000;
}
function centerCanvas(){
var canX = (windowWidth - width)/2;
var canY = (windowHeight - height)/2;
myCanvas.position(canX,canY);
}
function draw() {
// put drawing code here
centerCanvas();
dot.velocity.x = 0;
dot.velocity.y = 0;
if (keyIsDown(LEFT_ARROW)){
dot.velocity.x = -5;
}
if (keyIsDown(RIGHT_ARROW)){
dot.velocity.x = 5;
}
if (keyIsDown(UP_ARROW)){
dot.velocity.y = -5;
}
if (keyIsDown(DOWN_ARROW)){
dot.velocity.y = 5;
}
//background(grayscale);
background(50);
//arrive to the checkpoint to reach to next stage
if(bg.overlapPixel(dot.position.x,dot.position.y)){
console.log('bg1 hit');
bg.visible = false;
bg.position.x = 3000;
bg2.position.x = 1366/2;
bg2.visible = true;
}
if(bg2.overlapPixel(dot.position.x,dot.position.y)){
console.log('bg2 hit');
bg2.visible = false;
bg2.position.x = 3000;
bg3.position.x = 1366/2;
bg3.visible = true;
}
if(bg3.overlapPixel(dot.position.x,dot.position.y)){
console.log('bg3 hit');
bg3.visible = false;
bg3.position.x = 3000;
end.position.x = 1366/2;
end.visible = true;
}
[[i] 本帖最後由 herbert99121 於 2019-4-9 11:59 PM 編輯 [/i]]