Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm crash coursing cocos2d-javascript with an extremely tight deadline and am finding very few javascript specific examples to draw from.

Currently I'm drawing sprites, moving them, then removing them using the common method:

var enemy = cc.Sprite.create(s_spritesheet, cc.rect(0, 0, 128, 149));
// other setters here
this.addChild(enemy);
var move = cc.MoveTo.create(3, cc.p(-300, 200));
var done = cc.CallFunc.create(function(node) {
    //remove from enemy array, which never has more than 10 items
    cc.ArrayRemoveObject(this.enemies, node);
    node.removeFromParent();
}, this);
enemy.runAction(cc.Sequence.create(move, done));

Works fine and the game runs as expected except that it has some noticeable lag at times and choppy movement in some browsers. So while researching ways to improve performance I see mention of texture atlas improving performance but no solid examples. Everything I find is related to iOS, which is syntactically different enough to be confusing given the short time frame I have to work with. I've looked over the docs, but without an example I'm guessing more than anything and SO could use a few more cocos2d-javascript examples.

So does anyone have a javascript example of how one would use a texture atlas for multiple objects using the same spritesheet? Or an explanation on why just using Sprite.create this way may not be the culprit for the lag and chop?

share|improve this question
add comment (requires an account with 50 reputation)

This question has an open bounty worth +50 reputation from Kai Qing ending in 19 hours.

This question has not received enough attention.

A basic example of texture atlas would benefit everyone using cocos2d-javascript

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.