I’m make painting application.
painting some colors are fine but eraser has some problems.
here is my code,
void HelloWorld::onTouchesMoved(const std::vector<Touch*>&touches, Event* unused_event)
{
pRTex->begin();
float distance = start.getDistance(end);
if (distance > 1)
{
int d = (int)distance;
_erasers.clear();
for(int i = 0; i < d; ++i)
{
DrawNode* node = DrawNode::create();
if(modeBit==2)
node->drawDot(Vec2(),eraser_size,Color4F(0,0,0,0));
else
node->drawDot(Vec2(),eraser_size,Color4F::BLACK);
_erasers.pushBack(node);
}
for (int i = 0; i < d; i++)
{
float difx = end.x - start.x;
float dify = end.y - start.y;
float delta = (float)i / distance;
_erasers.at(i)->setPosition(Vec2(start.x + (difx * delta), start.y + (dify * delta)));
_erasers.at(i)->setRotation(rand() % 360);
float r = (float)(rand() % 50 / 50.f) + 0.25f;
_erasers.at(i)->setScale(r);
if(modeBit==2)
_erasers.at(i)->setBlendFunc(blendFunc);
_erasers.at(i)->visit();
}
}
pRTex->end();
}
this eraser function has overhead that application slowed and stopped.
I’m sorry for proper english.
please help, Thanks