2013-08-31 4 views
1

Я сейчас пытаюсь сделать игру с хитрыми js, и я застрял в анимации спрайта. я не знаю, что я делаю неправильно ..Craftyjs Sprite Animation issue

Вот рабочий код: http://aaahdontpaintmeinred.me.pn/

Вот как я загрузить спрайт в моей загрузки сцены:

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

Хорошо, поэтому я решил проблему, используя версию 0.5.3.

По-прежнему не знаю, что происходит. Но постараюсь дать ответ здесь.

0

Используйте неминифицированную версию.

Я использовал Crafty v0.5.4 миниатюра, а анимация спрайтов не работала, никаких ошибок в консольном журнале.

Затем, после нескольких часов боев, я попробовал с неминифицированной версией, и анимация спрайтов начала работать правильно.