mirror of
https://github.com/photonstorm/phaser
synced 2024-11-17 18:28:57 +00:00
Added new Rectangle Arcade Physics Body type
This commit is contained in:
parent
c819599304
commit
adb28d2f6e
2 changed files with 51 additions and 0 deletions
41
src/physics/arcade/ArcadeRectangle.js
Normal file
41
src/physics/arcade/ArcadeRectangle.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Body = require('./Body');
|
||||
var Class = require('../../utils/Class');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* An Arcade Physics Image is an Image with an Arcade Physics body and related components.
|
||||
* The body can be dynamic or static.
|
||||
*
|
||||
* The main difference between an Arcade Image and an Arcade Sprite is that you cannot animate an Arcade Image.
|
||||
*
|
||||
* @class Rectangle
|
||||
* @memberof Phaser.Physics.Arcade
|
||||
* @constructor
|
||||
* @since 3.17.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
|
||||
* @param {number} x - The horizontal position of this Game Object in the world.
|
||||
* @param {number} y - The vertical position of this Game Object in the world.
|
||||
* @param {number} width - .
|
||||
* @param {number} height - .
|
||||
*/
|
||||
var ArcadeRectangle = new Class({
|
||||
|
||||
Extends: Body,
|
||||
|
||||
initialize:
|
||||
|
||||
function ArcadeRectangle (world, x, y, width, height)
|
||||
{
|
||||
Body.call(this, world, null, x, y, width, height);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = ArcadeRectangle;
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
var ArcadeImage = require('./ArcadeImage');
|
||||
var ArcadeSprite = require('./ArcadeSprite');
|
||||
var ArcadeRectangle = require('./ArcadeRectangle');
|
||||
var Class = require('../../utils/Class');
|
||||
var CONST = require('./const');
|
||||
var PhysicsGroup = require('./PhysicsGroup');
|
||||
|
@ -115,6 +116,15 @@ var Factory = new Class({
|
|||
return gameObject;
|
||||
},
|
||||
|
||||
rectangle: function (x, y, width, height)
|
||||
{
|
||||
var body = new ArcadeRectangle(this.world, x, y, width, height);
|
||||
|
||||
this.world.add(body);
|
||||
|
||||
return body;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Arcade Image object with a Static body.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue