LoginSignup
0
0

More than 1 year has passed since last update.

plunkerでvue その54

Posted at

概要

plunkerでvueやってみた。
phinaでbox2dやってみた。

サンプルコード


new Vue({
  el: '#app',
 data: {
  },
  beforeMount: function() {
        this.init()
    },
    methods: {
      init() {
phina.globalize();
var SCREEN_WIDTH = 640;
var SCREEN_HEIGHT = 960;
phina.define("MainScene", {
  superClass: 'DisplayScene',
  init: function() {
    this.superInit();
    this.backgroundColor = 'aqua';
    var layer = Box2dLayer({
      width: SCREEN_WIDTH,
      height: SCREEN_HEIGHT,
    }).addChildTo(this);

    var ball0 = CircleShape().addChildTo(this);
    ball0.setPosition(this.gridX.span(3), this.gridY.span(3));
    ball0.alpha = 0.5;
    layer.createBody({
      type: 'dynamic', 
      shape: 'circle',
    }).attachTo(ball0);

    this.ball1 = CircleShape().addChildTo(this);
    this.ball1.setPosition(this.gridX.span(4), this.gridY.span(3));
    this.ball1.alpha = 0.5;
    this.ball = layer.createBody({
      type: 'dynamic', 
      shape: 'circle',
    }).attachTo(this.ball1);

    var ball2 = CircleShape().addChildTo(this);
    ball2.setPosition(this.gridX.span(5), this.gridY.span(3));
    ball2.alpha = 0.5;
    layer.createBody({
      type: 'dynamic', 
      shape: 'circle',
    }).attachTo(ball2);

    var floor0 = RectangleShape({
      width: 500,
      height: 32,
    }).addChildTo(this);
    floor0.setPosition(this.gridX.span(4), this.gridY.span(9));
    floor0.alpha = 0.5;
    layer.createBody({
      type: 'static',       
      shape: 'box',
    }).attachTo(floor0).body.SetAngle(Math.degToRad(10));

    var floor1 = RectangleShape({
      width: 500,
      height: 32,
    }).addChildTo(this);
    floor1.setPosition(this.gridX.span(13), this.gridY.span(13));
    floor1.alpha = 0.5;
    layer.createBody({
      type: 'static',       
      shape: 'box',
    }).attachTo(floor1).body.SetAngle(Math.degToRad(-15));

  },
  update: function() {
    if (this.ball1.y > 900)
    {
      //alert(this.ball.body)
      //this.ball1.body.setPosition(this.gridX.span(4), this.gridY.span(3));
            var p = new b2.Vec2(0, 0);
            this.ball.body.SetPosition(p);

    }
  },
});
phina.main(function() {
  var app = GameApp({
    startLabel: 'splash',
    title: 'box2d',
  });
  app.run();
});

    },
  }
});





成果物

以上。

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