how to using ofxImagesequnce with <vector>???

hello

Vector, is there a way to use dynamic allocation.

Current building codes

I used addon(ofxImagesequence, ofxBox2d)

Constructs a sequence of images, but the current state is, and the entire animation is to behave.
I would like to implement is an array of five images sequence when it is created in the vector animation independently.

Try to ask for help to you.

testApp.h

  
ofxBox2d box2d;  
	vector	<ofxBox2dRect>	rects;  
	  
	ofxImageSequence	sequence[5];  
	vector	<ofxImageSequence *> ss;  

testApp.cpp
setup :

  
void testApp::setup(){  
	ofBackground(0, 0, 0);  
	  
	ofSetFrameRate(60);  
	ofSetVerticalSync(true);  
	  
	box2d.init();  
	box2d.setGravity(0, 0.7);  
	box2d.createGround();  
	box2d.setFPS(30.0);  
	  
	  
	int imageMaxNum = sizeof(sequence)/sizeof(sequence[0]);  
  
	for (int i = 0; i < imageMaxNum; i++) {  
		string name;  
		name+= "images/dandelion_"+ofToString(i+1)+"/dandelion_"+ofToString(i+1)+"_";  
		sequence[i].loadSequence(name, "tga", 1, 190, 4);  
		sequence[i].preloadAllFrames();  
		sequence[i].setFrameRate(30);  
	}  
  
}  
  
  
//--------------------------------------------------------------  
void testApp::update(){  
	box2d.update();	  
	  
	if(ofGetFrameNum() % 15 == 0) {  
		float r = ofRandom(40, 15);		// a random radius 4px - 20px  
		float rWidth = ofRandom(ofGetWidth() );  
		ofxBox2dRect rect;  
		  
			rect.color.r = 255;  
			rect.color.g = 200;  
			rect.color.b = 0;  
			rect.color.a = 255;  
		  
		rect.setPhysics(1, 0.2, 0.05); //density, bounce, friction  
		rect.setup(box2d.getWorld(), rWidth, 0, r, r);  
		rects.push_back(rect);  
		  
		//-------------------------------------------------  
		b2Filter filterData;  
		//	filterData.groupIndex	= 2;		// group filtering has higher precedence than category filtering.  
			filterData.categoryBits	= 0x0001;	// if groupIndex is provided, categoryBits & maskBits is ignored.  
			filterData.maskBits		= 0x0001;	// read more on filtering under fixtures, [http://www.box2d.org/manual.html#-Toc258082972](http://www.box2d.org/manual.html#-Toc258082972)  
		  
		rect.setFilterData( filterData );  
		//-------------------------------------------------  
		  
			int selectImage = ofRandom(0, 5);  
			sequence[selectImage].setFrame(1);  
		ss.push_back( &sequence[selectImage]);  
	}  
	  
	  
	for(int i=0; i<rects.size(); i++) {  
		ss[i]->setFrameForTime(ofGetElapsedTimef());  
		  
		if(rects[i].getPosition().y >= ofGetHeight()-50){  
			rects[i].color.a -= 1;  
						  
			if (rects[i].color.a <= 0) {  
				rects[i].destroy();  
				rects.erase(rects.begin()+i);  
				  
				ss.erase(ss.begin()+i);  
			}  
		}		  
	}  
	  
}  
  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	  
	for(int i=0; i<rects.size(); i++) {  
		//ofFill();  
//		rects[i].draw();  
		  
		ofPushMatrix();  
		ofTranslate(rects[i].getPosition().x, rects[i].getPosition().y, 0);  
		ofRotate(rects[i].getRotation(), 0, 0, 1);  
		  
		ofEnableAlphaBlending();  
		ofSetColor(255, rects[i].color.a);		  
		  
		ss[i]->getTextureReference().draw(-rects[i].getWidth(), -rects[i].getHeight(),   
					 rects[i].getWidth()*2, rects[i].getHeight()*2);  
  
		  
		ofDisableAlphaBlending();  
		  
		ofPopMatrix();  
	}  
	  
	string info = "";  
	info += "Total Bodies: "+ofToString(box2d.getBodyCount())+"\n";  
	info += "Total Texture: "+ofToString(ss.size())+"\n";  
  
	info += "FPS: "+ofToString(ofGetFrameRate(), 1)+"\n";  
	ofSetHexColor(0x444342);  
	ofDrawBitmapString(info, 30, 30);  
}  

I am not certain but I think I know what you are asking :slight_smile:

Since you are storing pointers in

  
vector  <ofxImageSequence *> ss;   

you can remove

  
  
ofxImageSequence    sequence[5];    
  

And use ss dynamically

  
  
int imageMaxNum = 5;  
  
for (int i = 0; i < imageMaxNum; i++)   
{    
  string name;    
  name+= "images/dandelion_"+ofToString(i+1)+"/dandelion_"+ofToString(i+1)+"_";   
  ofxImageSequence *imageSequence  = new ofxImageSequence();  
  imageSequence->loadSequence(name, "tga", 1, 190, 4);    
  imageSequence->preloadAllFrames();    
  imageSequence->setFrameRate(30);    
  ss.push_back(imageSequence);  
}  
  

Thank you.^^
With your help, we were able to solve a single problem.

But again the problem has occurred.
The following code generates whenever it cuts off the frame each time, try it works.

what’s the problem?

  
if(ofGetFrameNum() % 15 == 0) {  
		float r = ofRandom(40, 15);		// a random radius 4px - 20px  
		float rWidth = ofRandom(ofGetWidth() );  
		ofxBox2dRect rect;  
		  
			rect.color.r = 255;  
			rect.color.g = 200;  
			rect.color.b = 0;  
			rect.color.a = 255;  
		  
		rect.setPhysics(1, 0.2, 0.05); //density, bounce, friction  
		rect.setup(box2d.getWorld(), rWidth, 0, r, r);  
		rects.push_back(rect);  
		  
		//-------------------------------------------------  
		b2Filter filterData;  
		//	filterData.groupIndex	= 2;		// group filtering has higher precedence than category filtering.  
			filterData.categoryBits	= 0x0002;	// if groupIndex is provided, categoryBits & maskBits is ignored.  
			filterData.maskBits		= 0x0001;	// read more on filtering under fixtures, [http://www.box2d.org/manual.html#-Toc258082972](http://www.box2d.org/manual.html#-Toc258082972)  
		  
		rect.setFilterData( filterData );  
		//-------------------------------------------------  
		float rr = ofRandom(1, 5);  
		  
		string name;  
		name+= "images/dandelion_"+ofToString(rr)+"/dandelion_"+ofToString(rr)+"_";  
		  
		ofxImageSequence *imgSequence = new ofxImageSequence();  
		imgSequence->loadSequence(name, "tga", 1, 190, 4);  
		imgSequence->preloadAllFrames();  
		imgSequence->setFrameRate(30);  
		imgSequence->setFrame(1);  
		  
		sss.push_back( imgSequence);  
	}