美文网首页
Action-批处理

Action-批处理

作者: skoll | 来源:发表于2023-03-22 20:05 被阅读0次

简介

1 .感觉是用来操作一组的对象,比如对象按照序列排队之类的
2 .
3 .让背景图完全覆盖画布大小
4 .

Phaser.Actions.GridAlign

1 .让一组对象网格对齐,比如种菜。根据为该操作提供的网格配置对齐它们

this.group=this.add.group({
      key:"diamonds",
      frame:[0,1,2,3,4],
      frameQuantity:20,
    })
//创建了一组对象,为啥这里直接就是100个呢,组内就直接创建出来这么多

Phaser.Actions.GridAlign(this.group.getChildren(),{
      width:4,
//横向摆放几个子元素
      height:3,
//纵向摆放几个子元素
      cellHeight:32,
//每个子元素的高度
      cellWidth:32,
//每个子元素的宽度
      x:500,
      y:500
    })

2 .摆放的时候怎么选择想要展示的对象,现在好像控制不了

让一组对象有层级,并且自己还在运动,比如旋转啥的

1 .感觉是让一组对象具有x的对象,把变化的值加到x上面,就是控制x的变化
2 .创建一个组,组里面添加元素
3 .update里面迭代这一组元素

this.groupA=this.add.group()
    for(let i=0;i<100;i++){
      this.groupA.create(100 + Math.random() * 600, 100 + Math.random() * 400,'atlas','veg0'+Math.floor(1+Math.random()*9))
    }
 Phaser.Actions.IncX(this.groupA.getChildren(),Math.cos(this.move))
    Phaser.Actions.IncY(this.groupA.getChildren(),Math.cos(this.move))
    Phaser.Actions.Rotate(this.groupA.getChildren(),-0.01)
    this.move+=0.01

4 .类似的操作,还有IncX,InY,InXY,x方向渐变,y方向渐变
5 .Rotate,旋转
6 .

RotateAroundDistance

1 .按给定的角度和距离围绕一个点旋转一组游戏对象

this.tween=this.tweens.addCounter({
      from:220,
      to:300,
      duration:3000,
      delay:2000,
      ease:'Sine.easeInOut',
      repeat:-1,
      yoyo:true
    })
//create里面 创建一个动画数的递增渐变。此时这个动画一直在重复的变化 220-300 这个值,下面的getValue()函数可以取到变化的值

update 里面调用这个
Phaser.Actions.RotateAroundDistance(this.group.getChildren(),{x:this.x,y:this.y},0.02,this.tween.getValue())
//本来update 是个连续的回调,但是使用这个函数就感觉是瞬间的动作加了进去
1 .0.02是每次旋转的角度
2 .this.tween.getValue() 是园的半径,在这里他是一个连续变化的值
3 .所以最后的效果就是一个园环在不停的旋转,旋转的时候大小还在变化 

Phaser.Actions.PlaceOnCircle(this.group.getChildren(), circle) 按照圆形放置元素

1 .按照给定的圆形路径放置元素

在某一块区域内,随机分配一些东西,允许重叠

1 .不允许重叠的版本需要插件实现
2 .

人物背景:让一些东西沿着圆环 旋转,一环套一环,就像小行星带一样

1 .

 this.group1 = this.add.group({
      key: 'fire', frameQuantity: 36
    })

    this.circle1 = new Phaser.Geom.Circle(this.x, this.y, 360)
    Phaser.Actions.PlaceOnCircle(this.group1.getChildren(),this.circle1)

Phaser.Actions.RotateAroundDistance(this.group1.getChildren(),this.circle1,-0.010,this.circle1.radius)

按照直线分布展示元素

this.line=new Phaser.Geom.Line(this.x,this.y+100,this.x+500,this.y+100)
    Phaser.Actions.PlaceOnLine(this.group1.getChildren(),this.line)

放置在园的一部分

1 .在某个矩形内序列分布一些园
2 .实际的实现就是多画了几个园

沿着矩形放置

1 .获取一组游戏对象并将它们放置在矩形周边均匀分布的点上。
2 .this.i是 位置的偏移量

Phaser.Actions.PlaceOnRectangle(this.group.getChildren(),this.rect,this.i)

在圆内随机放置

1 .感觉这个随机还是可以的

this.rect=new Phaser.Geom.Rectangle(this.x,this.y,this.x,this.y+100)
    this.group=this.add.group({
      key:"diamonds",
      frame:[0,1,2,3,4],
      frameQuantity:50
    })
    Phaser.Actions.RandomRectangle(this.group.getChildren(),this.rect)

三角区域内随机放置

this.triangle=new Phaser.Geom.Triangle.BuildEquilateral(400,100,380)
    this.group=this.add.group({
      key:"diamonds",
      frame:[0,1,2,3,4],
      frameQuantity:50
    })
    Phaser.Actions.RandomTriangle(this.group.getChildren(),this.triangle)

围绕一个点旋转,可以引申出很多玩法

1 .比如沿着鼠标旋转,鼠标走到哪里,旋转到哪里

this.group = this.add.group({
      key: "diamonds",
      frame: [0, 1, 2, 3, 4],
      frameQuantity: 50
    })
    this.gemoPoint = new Phaser.Geom.Point(400, 300)
    this.input.on('pointermove', function (pointer) {
      this.gemoPoint.setTo(pointer.x, pointer.y)
    }, this)

2 .新建的点,更新点的位置

ShiftPosition

1 .遍历 items 数组,将每个元素的位置更改为数组中位于它之前的元素的位置(如果方向 = 1,则位于它之后)第一个项目位置设置为 x/y。
2 .贪吃蛇 表现

包裹在矩形中

1 .一个正方形中,叶子随风摆动,出了正方形就消失。或者说下雨,下雪。也就是运动出去了,他会在拿回来

this.rect=new Phaser.Geom.Rectangle(0,0,1000,1000)
this.group=this.add.group({key:"fire",frameQuantity:10})
Phaser.Actions.RandomRectangle(this.group.getChildren(),this.rect)

Phaser.Actions.IncXY(this.group.getChildren(),1,1)
Phaser.Actions.WrapInRectangle(this.group.getChildren(),this.rect)

2 .创建大小的新方式,创建一个摄像机大小的矩形,然后再矩形内添加全局元素,比如星星,比如落叶

this.rect=Phaser.Geom.Rectangle.Clone(this.cameras.main)

this.group.getChildren().forEach((shape,i)=>{
      shape.x += (1 + 0.1 * i);
      shape.y += (1 + 0.1 * i);
    })
//每个元素的位置是随机的,现在还不是随机的,可以拿正弦函数变化的值。那个this.tweens返回的值

    Phaser.Actions.WrapInRectangle(this.group.getChildren(),this.rect)

PlayAnimation(items, key [, startFrame])

1 .如果传入的是一个精灵,还可以从某一帧开始播放
2 .

PropertyValueInc

1 .获取一个游戏对象数组,或任何具有 中定义的公共属性的对象key,然后将给定值添加到其中。可选step属性以递增方式应用,乘以数组中的每个项目
2 .感觉这个方法最能代表,就是一个包装起来的方法。核心是遍历组内的全部对象,然后做一些操作。
3 .然后他再这里给了很多方法来让你用

shuffle

1 .打乱一组数组里面的数据
2 .

在两个属性值之间展示所有对象

Phaser.Actions.Spread(group.getChildren(), 'alpha', 0, 1);

总结

1 .就是用来对一组数据进行一些位置,属性上的规律变化
2 . RotateAroundDistance 注意这个函数的使用,可以实现很多厉害的效果。
3 .SetDepth 不用每一个实例化的时候自己搞了 之前是自己单独配置的
4 .SetHitArea 设置可点击区域
5 .toggleVisible 直接控制全部元素的展示和消失

相关文章

  • redux

    安装redux Redux的组成 Action-事件 Reducer Store 案例

  • Hadoop之操作篇

    【基础篇】 连接AWS action->start,connect 打开terminal cd key-pair....

  • redux-thunk的一点认识

    redux-thunk是什么东西 在此之前先回顾下redux的工作流程:action-> dispatcher -...

  • 批处理书目录

    批处理典型业务场景 批处理关键领域模型及关键架构 批处理实现作业的健壮性与扩展性 批处理框架的不足与增强

  • redux中间件执行原理?

    学习过react的同学肯定都用过redux。了解redux数据流机制的action->dispatch->stor...

  • start与call的区别

    1.call是从批处理程序调用另一个批处理程序,并且不终止父批处理程序(如果不用call而直接调用别的批处理文件,...

  • java程序员笔记--Dubbo服务接口的设计原则

    1.设计方式 action->facade->biz->dao 好的Dubbo服务接口设计,并非只是纯粹的接口服务...

  • dos之批处理命令学习及常用批处理

    批处理 参考文章 w3cshcoolwindows批处理语法——可可西批处理基本语法整理(一)——正在崛起的小菜菜...

  • 批处理收集

    批处理判断系统执行 批处理读取配置文件 配置文件config.ini内容如下 批处理内容如下 Origin创建桌面...

  • JavaMysql批处理

    写在前面 添加批处理preparedStatement.addBatch(); 执行批处理preparedStat...

网友评论

      本文标题:Action-批处理

      本文链接:https://www.haomeiwen.com/subject/nerprdtx.html