Skip to main content
deleted 60 characters in body
Source Link
Tetrad
  • 30.1k
  • 12
  • 96
  • 143

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist");
    CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png");
    w.addChild(spriteSheet);
    
    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

Please help.

PS: This code doesn't crash!!! Nothing just happen..

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

Please help.

PS: This code doesn't crash!!! Nothing just happen..

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code:

    CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist");
    CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png");
    w.addChild(spriteSheet);
    
    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

added 56 characters in body
Source Link
user729053
  • 147
  • 1
  • 5

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

Please help.

PS: This code doesn't crash!!! Nothing just happen..

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

Please help.

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

Please help.

PS: This code doesn't crash!!! Nothing just happen..

added 29 characters in body
Source Link
user729053
  • 147
  • 1
  • 5

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.jpg"png");

What do I do wrong? How can I fix thisCan someone provide me of a snippet of animation using a spritesheet?

Please help.

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.jpg");

What do I do wrong? How can I fix this?

Please help.

I'm trying to animate a sprite in a spritesheet, the goal is to make the character walk from left to right. I subclassed CCSprite: CharacterSprite.

this is my code: CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("WalkAnimation.plist"); CCSpriteSheet spriteSheet = CCSpriteSheet.spriteSheet("WalkAnimation.png"); w.addChild(spriteSheet);

    ArrayList<CCSpriteFrame> walkSprites = new ArrayList<CCSpriteFrame>();
    for(int i = 1; i<=8;++i)
    {
        walkSprites.add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("walk"+ i +".png"));
    }
    //float randomFactor = (float)Math.random()*10;  
    CCAnimation walkAnimation = CCAnimation.animation("walk", 0.1f, walkSprites);
    
    Log.v("addEnemy", "Show");
    this.character = CCSprite.sprite(walkSprites.get(0));
    
    Log.v("addEnemy", "Don't Show");
    
    
    this.walkAction = CCRepeatForever.action(CCAnimate.action(walkAnimation, false));
    character.runAction(walkAction);        
    
    for(int k =0; k<amount; k++)
    {
        float randomFactor = (float)Math.random()*10;
        character.setPosition(CGPoint.ccp(-randomFactor * character.getContentSize().width/2, winSize.height / 6.0f));
        spriteSheet.addChild(character);
    }

This code is in my 2nd scene. And whenever I press on Start Game, nothing happens. But the code is executed till: character = CharacterSprite.sprite("walk1.png");

Can someone provide me of a snippet of animation using a spritesheet?

Please help.

change my code
Source Link
user729053
  • 147
  • 1
  • 5
Loading
Source Link
user729053
  • 147
  • 1
  • 5
Loading