java - How to set frame of CCSprite -


i have class of character in ccsprite variable. character moving point , animating walking animation after touching button or jumping, works fine, after animation ccsprite has bad frame(one of walking frame). @ end of update function wrote code, frozen, character cant jump or walk more, number of running actions 1:

if(this.sprite.numberofrunningactions() == 0){   if(this.state != characterstate.idle){     this.changestate(characterstate.idle); // without row works still fine   } } 

changestate function:

public void changestate(characterstate state){   sprite.stopallactions();   this.state = state;   switch(state){     case idle:{ this.sprite = ccsprite.sprite(ccspriteframecache.sharedspriteframecache().spriteframebyname("player.png")); break;}     case walk_left:{ this.sprite.runaction(waction); break; }      .      .      . 

ok, solved alone. :) have created class variable of ccspriteframe type.

ccspriteframe frame_idle; 

in class constructor:

frame_idle = ccspriteframecache.sharedspriteframecache().spriteframebyname("player.png"); 

and case idle have changed to:

case idle:{ this.sprite.setdisplayframe(frame_idle); break; } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -