Jump to content

error using groups


pranadevil
 Share

Recommended Posts

hi buddies,

 

got this code :

 

additem:function()
    {
 
        
        box_ = this.box.getRandom();
        
        if(!box_){
        
        gameText.setText("now: NULLLLLLLLLLLLL"+box_.name);
        return;
        }
        gameText.setText("now: "+box_.name);
        box_.anchor.setTo(0.5,0.5);
        box_.reset(20,740);
        box_.body.velocity.x = -50;
    
       
        
        
    }
 
 
 
but when running got the error  ;Uncaught TypeError: Cannot read property 'velocity' of null ........................................... line 150 (box_.body.velocity.x = -50;)
 
 
this.box is a group with several sprites, fullfilled with a for loop. gameText is a text variable in which i got the name of each item, but it nevers shows "NULLLLLLLLLLLL" 
 
so what im forgetting? why the box_ variable doesnt has the body.velocity.x ???
 
 
 
thanks in advance
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...