phaser-framework - 向场景添加补间但不立即播放
问题描述
我正在将补间添加到场景中scene.add.tween({config})
,并且添加的补间会自动播放。我怎样才能防止这种情况?
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: { y: 200 }
}
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.setBaseURL('http://labs.phaser.io');
this.load.image('logo', 'assets/sprites/phaser3-logo.png');
}
function create ()
{
var logo = this.add.image(config.width / 2, config.height / 2, 'logo');
var tween_logo = this.add.tween({
targets: logo,
duration: 1000,
scale: 2,
ease: 'Linear',
yoyo: true,
repeat: -1
});
}
<script src="https://cdn.jsdelivr.net/gh/photonstorm/phaser@3.18.1/dist/phaser.min.js"></script>
解决方案
在您的补间配置中添加 paused 属性并将其设置为 true。
因此,您的补间配置将是:
var tween_logo = this.add.tween({
targets: logo,
duration: 1000,
paused: true,
scale: 2,
ease: 'Linear',
yoyo: true,
repeat: -1
});
这是配置文档的链接,以查看其他属性:
推荐阅读
- sql-server - Azure SQL 数据库表变量排序规则
- php - 在 Woocommerce 中为可变产品设置最小单位显示价格
- amazon-web-services - AWS Cloudformation - 挂载到现有文件系统
- php - 具有热链接保护和低内存使用率的 Laravel 下载响应
- vba - Datediff 不适用于 VBA 查询以在 Excel 中访问
- anaconda - Spyder 终端在哪里(是的,我下载了它)?
- time - ISO-8601 UTC 和 Unix 时间戳之间是否存在一对一关系?
- javascript - 用于片段的 VSCode 文档选择器
- ruby-on-rails - 安装 Mysql 2 gem 失败
- matlab - 如何解释这些用 MATLAB 编写的命令行?