我正在使用带有 html5 的 cocos2d-js v3.0,我正在将一个 plist 加载到缓存中,并且我正在尝试从中创建一个精灵。
我收到错误
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (player-stand-f-0, line 0)
据我所知 .createWithSpriteFrameName 已被弃用,但所有示例都显示使用它。
编码:
var cache = cc.spriteFrameCache;
cache.addSpriteFrames(player.plist, player.png);
this.sprite = cc.Sprite.createWithSpriteFrameName("player-stand-f-0");
this.sprite.setPosition(new cc.Point(300,300));
this.addChild(this.sprite);
播放器.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>player-sit-f-0</key>
<dict>
<key>frame</key>
<string>{{3,108},{77,95}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{77,95}}</string>
<key>sourceSize</key>
<string>{77,95}</string>
</dict>