LoginSignup
0
0

概要

Plunkerで、Phaser.Physicsやってみた。

写真

image.png

サンプルコード

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { 
    preload: preload, 
    create: create, 
    render: render 
});
function preload() {
    //game.load.image('ball', 'assets/sprites/shinyball.png');
}
var circle
function create() {
    game.stage.backgroundColor = '#124184';
    game.physics.startSystem(Phaser.Physics.BOX2D);
    game.physics.box2d.gravity.y = 500;
    game.physics.box2d.restitution = 0.8;
    game.physics.box2d.setBoundsToWorld();

    var ball = game.add.sprite(400, game.world.centerY, 'ball');
    game.physics.box2d.enable(ball);
    ball.body.setCircle(ball.width / 2);

    var circle = game.physics.box2d.createCircle(300, 300, 32);

    var square1 = new Phaser.Physics.Box2D.Body(this.game, null, 200, 130, 2);
    square1.setRectangle(50, 50, 0, 0, 0);
    square1.friction = 0.4;
}
function render() {
    game.debug.box2dWorld();
}



成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0