跳转至

Phaser.GameObjects. Graphics#

new Graphics(scene [, options])#

// 通常通过Phaser.Scene.add.graphics()引用其工厂函数
let back_drop = this.add.graphics();
// 设置线型后才能画轮廓线
back_drop.lineStyle(15, 0x888888, 0.5);
// back_drop.fillStyle(color [, alpha]); //填充型,画面用

Extends#

Members#

TargetCamera :Phaser.Cameras.Scene2D.Camera#

active :boolean#

alpha :number#

angle :number#

blendMode :Phaser.BlendModes|string#

body :Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody|MatterJS.BodyType#

cameraFilter :number#

commandBuffer :array#

data :Phaser.Data.DataManager#

defaultFillAlpha :number#

defaultFillColor :number#

defaultPipeline :Phaser.Renderer.WebGL.WebGLPipeline#

defaultStrokeAlpha :number#

defaultStrokeColor :number#

defaultStrokeWidth :number#

depth :number#

displayList :Phaser.GameObjects.DisplayList|Phaser.GameObjects.Layer#

displayOriginX :number#

displayOriginY :number#

hasPostPipeline :boolean#

ignoreDestroy :boolean#

input :Phaser.Types.Input.InteractiveObject#

mask :Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask#

name :string#

parentContainer :Phaser.GameObjects.Container#

pipeline :Phaser.Renderer.WebGL.WebGLPipeline#

pipelineData :object#

postPipeline :Array.#

renderFlags :number#

rotation :number#

scale :number#

scaleX :number#

scaleY :number#

scene :Phaser.Scene#

scrollFactorX :number#

scrollFactorY :number#

state :number|string#

tabIndex :number#

type :string#

visible :boolean#

w :number#

x :number#

y :number#

z :number#

Methods#

addedToScene()#

addListener(event, fn [, context])#

arc(x, y, radius, startAngle, endAngle [, anticlockwise] [, overshoot])#

beginPath()#

clear()#

clearAlpha()#

clearMask( [destroyMask])#

closePath()#

copyPosition(source)#

createBitmapMask( [renderable])#

createGeometryMask( [graphics])#

destroy()#

disableInteractive()#

emit(event [, args])#

eventNames()#

fill()#

fillCircle(x, y, radius)#

fillCircleShape(circle)#

fillEllipse(x, y, width, height [, smoothness])#

fillEllipseShape(ellipse [, smoothness])#

fillGradientStyle(topLeft, topRight, bottomLeft, bottomRight [, alphaTopLeft] [, alphaTopRight] [, alphaBottomLeft] [, alphaBottomRight])#

渐变填充型

fillPath()#

fillPoint(x, y [, size])#

fillPoints(points [, closeShape] [, closePath] [, endIndex])#

fillPointShape(point [, size])#

fillRect(x, y, width, height)#

fillRectShape(rect)#

fillRoundedRect(x, y, width, height [, radius])#

圆角矩形。

let back_drop = this.add.graphics();
back_drop.lineStyle(15, 0x888888, 0.5);
//  用一个对象配置四角的圆度
back_drop.strokeRoundedRect(360, 240, 400, 300, { tl: 64, tr: 22, bl: 12, br: 0 });

fillStyle(color [, alpha])#

填充型

fillTriangle(x0, y0, x1, y1, x2, y2)#

fillTriangleShape(triangle)#

generateTexture(key [, width] [, height])#

getData(key)#

getIndexList()#

getLocalPoint(x, y [, point] [, camera])#

getLocalTransformMatrix( [tempMatrix])#

getParentRotation()#

getPipelineName()#

getPostPipeline(pipeline)#

getWorldTransformMatrix( [tempMatrix] [, parentMatrix])#

incData(key [, data])#

initPipeline(pipeline)#

lineBetween(x1, y1, x2, y2)#

// 画满灰色横条
let back_drop = this.add.graphics();
back_drop.lineStyle(15, 0x888888, 0.5);
const width = this.game.scale.width;
let height = this.game.scale.height;
const space = 30;
let y = 0;
while (height > y) {
    back_drop.lineBetween(0, y, width, y);
    y += space;
}

lineGradientStyle(lineWidth, topLeft, topRight, bottomLeft, bottomRight [, alpha])#

lineStyle(lineWidth, color [, alpha])#

轮廓线型。

lineTo(x, y)#

listenerCount(event)#

listeners(event)#

moveTo(x, y)#

off(event [, fn] [, context] [, once])#

on(event, fn [, context])#

once(event, fn [, context])#

preDestroy()#

removeAllListeners( [event])#

removedFromScene()#

removeInteractive()#

removeListener(event [, fn] [, context] [, once])#

removePostPipeline(pipeline)#

resetPipeline( [resetPostPipelines] [, resetData])#

resetPostPipeline( [resetData])#

restore()#

rotateCanvas(radians)#

save()#

scaleCanvas(x, y)#

setActive(value)#

setAlpha( [value])#

setAngle( [degrees])#

setBlendMode(value)#

setData(key [, data])#

setDataEnabled()#

setDefaultStyles(options)#

setDepth(value)#

setInteractive( [hitArea] [, callback] [, dropZone])#

setMask(mask)#

setName(value)#

setPipeline(pipeline [, pipelineData] [, copyData])#

setPipelineData(key [, value])#

setPosition( [x] [, y] [, z] [, w])#

setPostPipeline(pipelines [, pipelineData] [, copyData])#

setRandomPosition( [x] [, y] [, width] [, height])#

setRotation( [radians])#

setScale(x [, y])#

setScrollFactor(x [, y])#

setState(value)#

setVisible(value)#

setW( [value])#

setX( [value])#

setY( [value])#

setZ( [value])#

shutdown()#

slice(x, y, radius, startAngle, endAngle [, anticlockwise] [, overshoot])#

stroke()#

strokeCircle(x, y, radius)#

strokeCircleShape(circle)#

strokeEllipse(x, y, width, height [, smoothness])#

strokeEllipseShape(ellipse [, smoothness])#

strokeLineShape(line)#

strokePath()#

strokePoints(points [, closeShape] [, closePath] [, endIndex])#

strokeRect(x, y, width, height)#

strokeRectShape(rect)#

strokeRoundedRect(x, y, width, height [, radius])#

strokeTriangle(x0, y0, x1, y1, x2, y2)#

strokeTriangleShape(triangle)#

toggleData(key)#

toJSON()#

translateCanvas(x, y)#

update( [args])#

willRender(camera)#