1

In cocos2D-HTML5 I can't create 2 instances from 1 class. I use the engine cocos2D HTML 5 version. The issues is I have a moving platform the first created instance will move. When I add the second platform. The first and second platform won't move.

This is my code to create new instances:

addPlatform:function(parentObj)
{  
    window.setTimeout(function(){ 
        var platform = new Player();       
        platform.init(null);
        platform.setPlatformPosition(coords[0].x,coords[0].y);
        platforms.push(platform);
        parentObj.addChild(platforms[0]);  },3000);
    window.setTimeout(function(){ 
        var platform2 = new Player();       
        platform2.init(null);
        platforms.push(platform2);
        platform2.setPlatformPosition(coords[1].x,coords[1].y);
        parentObj.addChild(platforms[1]);  },6000);
    //console.log(platforms[1]);
},

To see the bug please visit this website

Thank you

CodeSmile
  • 64,284
  • 20
  • 132
  • 217

0 Answers0