5

i need to invoke a method of class A (it extends CCColorLayer) from a method of class B (it extends activity). How is it possible? Tried creating object for Class A in class B. But its not the solution. Each time its creating different layer. please help.

Thanks in advance.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
Arun Jose
  • 1,857
  • 1
  • 15
  • 24
  • Could you please post some code that shows what you are trying to do. Normally you would invoke a method of class A on an object of type A. So this means that you would have to create an instance of class A to operate on. Your question isn't clear. – David Wasser May 03 '13 at 13:28

1 Answers1

0

Are you looking to create a singleton pattern??

 public Class A extends CCcolorlayer
    { 
    private static final A INSTANCE= new A();
     A() 
    { 
    }
     public static A getInstance() 
    { return INSTANCE; 
    } 

    }

From Class B

 public class B
{
   B()
     {
        A.getInstance();// which returns object of the class A.(you dont need to create object of class A everytime.)
     }

}

Im not sure whether you are looking for this.

playmaker420
  • 1,527
  • 4
  • 27
  • 52