//bounce1
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
sp = createSprite(30, 30, 30, 30);
sp.draw = function(){
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
}
function draw() {
background(205,255,255);
sp.bounce(wall);
drawSprites();
}
preview
//bounce2
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
}
function draw() {
background(205,255,255);
sp.bounce(wall, explosion);
// sp.bounce(wall);
drawSprites();
}
function explosion(sp, wall) {
wall.remove();
}
preview
//////////////////////////////////
//collide
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
}
function draw() {
background(205,255,255);
sp.collide(wall);
drawSprites();
}
preview
//collide2
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
}
function draw() {
background(205,255,255);
sp.collide(wall, explosion);
// sp.bounce(wall);
drawSprites();
}
function explosion(sp, wall) {
wall.shapeColor = color(0, 0, 255);
wall.position.x +=5;
}
preview
///////////////////////////////////
//displace
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
}
function draw() {
background(205,255,255);
sp.displace(wall);
drawSprites();
}
preview
//displace2
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
}
function draw() {
background(205,255,255);
sp.disp lace(wall, explosion);
// sp.bounce(wall);
drawSprites();
}
preview
///////////////////////////////
//overlap
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
}
function draw() {
background(205,255,255);
sp.overlap(wall, overlapped);
// sp.bounce(wall);
drawSprites();
}
preview
//overlap2
var wall, sp;
function setup() {
var myCanvas = createCanvas(300, 300);
myCanvas.parent('myContainer');
sp = createSprite(30, 30, 30, 30);
sp.draw = function() {
fill(237,205,0);
ellipse(0,0, 30, 30);
}
sp.velocity.x = sp.velocity.y = 2;
wall = createSprite(60, 200, 340, 20);
wall.shapeColor = color(0,135,155);
wall.immovable = true;
}
function draw() {
background(205,255,255);
sp.overlap(wall, overlapped);
// sp.bounce(wall);
drawSprites();
}
/////////////////////////
コメントを残す