我对理解某些代码有一些问题
(function (lib_p, img, cjs) {
var p; // shortcut to reference prototypes
// library properties:
lib_p.properties = {
width: 364,
height: 540,
fps: 20,
color: "#000000",
manifest: [
{src:"img/bot1_l.png", id:"bot1_l"}
]
};
// symbols
(lib_p.bot1_l = function() {
this.initialize(img.bot1_l);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,116,344);
我在哪里可以读到这个?我知道这是createJS,但我不知道这是什么意思 - 特别是:
(lib_p, img, cjs)
,
(lib_p.bot1_l = function(){ this.initialize(img.bot1_l); })。原型= p = new cjs.Bitmap(); p.nominalBounds = new cjs.Rectangle(0,0,116,344);
答案 0 :(得分:2)
cjs.Rectangle
p
的实例,将其分配给变量p
,创建一个函数,将prototype
的值赋给bot1_l
属性然后将新函数分配给任何对象lib_p
所指向的public class RelativeResource extends AbstractResource {
private final String relativePath;
public RelativeResource(String relativePath) {
this.relativePath = relativePath;
}
@Override
public String getDescription() {
return "RelativeResource [" + relativePath + "]";
}
@Override
public boolean isReadable() {
File resourceFile = new File(getAbsoluteFileLocation());
return resourceFile.exists();
}
@Override
public boolean isOpen() {
return true;
}
@Override
public InputStream getInputStream() throws IOException {
return new FileInputStream(getAbsoluteFileLocation());
}
private String getAbsoluteFileLocation() {
return Paths.get("").toAbsolutePath().resolve(relativePath).toString();
}
}
属性。