Hi, world, i have i little probleme with a class array, i have some strange message like "ClassCastException: Ljava.lang.object; cannot be cast to [Ltest_array$myArray....."
I can use splice with an array object?
I make all my code, it's more easy if you want try.
Thank you very munch for your help!
////////////////MAIN
import processing.opengl.*;
myArray [] ArrayBig = new myArray[3];
void setup(){
size(800,600,OPENGL);
background(0);
mouseX = 40;
for(int i=0;i<ArrayBig.length;i++){
ArrayBig[i] = new myArray(Xref+50*i,y);
}
}
int y = 100;
int x=0;
void draw(){
background(0);
for(int i=0;i<ArrayBig.length;i++){
ArrayBig[i].update(Xref+-2*50+50*i,y);
}
change();
}
int Xref = 100;
int multi = 1;
void change(){
if(mouseX>Xref){
changeRight();
multi++;
Xref += 50;
}
if(mouseX<Xref-100){
changeLeft();
multi--;
Xref -= 50;
}
}
void changeRight(){
myArray [] ArrayBig2 = (myArray[]) subset(ArrayBig,1);
ArrayBig = ArrayBig2;
myArray [] ArrayBig3 = (myArray[]) append(ArrayBig,new myArray(Xref+-2*50+50*3,y));
ArrayBig = ArrayBig3;
}
void changeLeft(){
myArray [] ArrayBig2 = (myArray[]) subset(ArrayBig,3);
ArrayBig = ArrayBig2;
//My problem is here....
myArray [] ArrayBig3 = (myArray[]) splice(ArrayBig,(new myArray(Xref+-2*50+50*3,y)),0);
ArrayBig = ArrayBig3;
}
////////////////CLASS myArray
class myArray{
int R,V,B;
myArray(int x,int y){
R = round(random(255));
V = round(random(255));
B = round(random(255));
rect(x,y,50,50);
}
void update(int x,int y){
stroke(255);
strokeWeight(.1);
fill(R,V,B);
rect(x,y,50,50);
}
}
//////////////////////////////////////