【发布时间】:2014-11-22 01:27:53
【问题描述】:
我在阅读Crafty tutorial 时遇到了一个我找不到文档的代码 sn-p。标点符号太难找了。
有问题的第 11 行和第 12 行遵循Crafty.e 行并以.text 和.css 开头。这些属性属于什么对象?
//the loading screen that will display while our assets load
Crafty.scene("loading", function () {
//load takes an array of assets and a callback when complete
Crafty.load(["sprite.png"], function () {
Crafty.scene("main"); //when everything is loaded, run the main scene
});
//black background with some loading text
Crafty.background("#000");
Crafty.e("2D, DOM, Text").attr({ w: 100, h: 20, x: 150, y: 120 })
.text("Loading")
.css({ "text-align": "center" });
});
//automatically play the loading scene
Crafty.scene("loading");
这在规范中的什么地方?
【问题讨论】:
-
大声笑 - 很多快速的答案。
-
它被称为fluent interface,如果你熟悉php,有几个ORM框架都在使用它。
-
感谢大家的精彩解释。我现在觉得很傻。当然,点是一个运算符,因此可以有空格围绕它。
-
@JeffStrunk 不必觉得自己很愚蠢——这种事情在我们所有人身上都会时不时发生,甚至在我们的一生中会发生好几次。
标签: javascript