Javascript Craftyjs精灵动画问题
我目前正在尝试用狡猾的js制作一个游戏,我一直在玩精灵动画。 我真的不知道我做错了什么 以下是工作代码: 以下是如何在加载场景中加载精灵:Javascript Craftyjs精灵动画问题,javascript,animation,craftyjs,Javascript,Animation,Craftyjs,我目前正在尝试用狡猾的js制作一个游戏,我一直在玩精灵动画。 我真的不知道我做错了什么 以下是工作代码: 以下是如何在加载场景中加载精灵: Crafty.scene('Loading', function(){ // Draw some text for the player to see in case the file // takes a noticeable amount of time to load Crafty.e('2D, DOM, Text') .text('Loading
Crafty.scene('Loading', function(){
// Draw some text for the player to see in case the file
// takes a noticeable amount of time to load
Crafty.e('2D, DOM, Text')
.text('Loading...')
.attr({ x: 0, y: Game.height()/2 - 24, w: Game.width() });
// Load our sprite map image
Crafty.load(['assets/mansprite.gif'], function(){
// Once the image is loaded...
// Define the individual sprites in the image
// Each one (spr_tree, etc.) becomes a component
// These components' names are prefixed with "spr_"
// to remind us that they simply cause the entity
// to be drawn with a certain sprite
Crafty.sprite(133, 'assets/mansprite.gif', {
mansprite:[0, 0]
});
// Now that our sprites are ready to draw, start the game
Crafty.scene('LevelEditor');
})
})
下面是我如何尝试在播放器组件中绑定和设置动画:
Crafty.c('PlayerCharacter', {
init: function() {
this.requires('Actor, Collision,FPS,mansprite,SpriteAnimation,WiredHitBox')
.attr({maxValues:1,boost:false,trailSpacing:100,currentFrame:0})
.collision();
this.animate('run',0, 0, 3);
this.animate('idle',3, 0, 1);
this.requires('FluidControls')
//this.rotation+=90;
.onHit("FinishLine",this.endLevel)
.onHit("DeathWall",this.omagaDie)
.onHit("Booster",this.booster)
.bind("EnterFrame",function(fps){
if(this.move.up)
{
this.animate('run', 4,-1);
var spacing = this.trailSpacing;
if( this.currentFrame%((60*spacing)/1000) == 0)
Crafty.e("montexte").spawn(this.x,this.y,this.boost,this.xspeed,this.yspeed,this.rotation%360,this.h,this.w);
}else
{
if(!this.move.down)
{
this.animate('idle', 4,1);
}
}
this.currentFrame++;
if(this.currentFrame >=60)
this.currentFrame=0
})
;
},
希望有人能指出哪里出了问题!
如果你需要更多的细节或者你有问题,不要犹豫!
谢谢好的,所以我用0.5.3版本解决了这个问题
还是不知道发生了什么。但是我会尝试在这里给出答案。使用非精简版本 我使用的是狡猾的v0.5.4缩小版,精灵动画不工作,控制台日志中没有错误 经过几个小时的努力,我尝试了非缩小版,精灵动画开始正常工作