Example #1
0
//! [1]
void DiagramScene::setLineColor(const QColor &color)
{
    myLineColor = color;
    if (isItemChange(Arrow::Type)) {
        Arrow *item =
            qgraphicsitem_cast<Arrow *>(selectedItems().first());
        item->setColor(myLineColor);
        update();
    }
}
Example #2
0
void OdometryDisplay::updateLength()
{
  float length = length_property_->getFloat();
  D_Arrow::iterator it = arrows_.begin();
  D_Arrow::iterator end = arrows_.end();
  Ogre::Vector3 scale( length, length, length );
  for ( ; it != end; ++it )
  {
    Arrow* arrow = *it;
    arrow->setScale( scale );
  }
  context_->queueRender();
}
Example #3
0
void BattleLayer::addArrowToBattleMap(const cocos2d::Vec2 &fromPoint, const cocos2d::Vec2 &toPoint, const std::function<void ()> &callback){
    CCLOG("%s, ", __func__);
    Arrow *arrow = Arrow::createArrow(fromPoint, toPoint, this);
    arrow->setPosition(fromPoint);
    _battleMap->addChild(arrow, 10000);
    
    float duration = getDistanceWithTowVec2(fromPoint, toPoint) / GameData::getInstance()->getBattleWeaponSpeed(BattleWeapon::Arrow);
    
    arrow->runAction(Sequence::create(MoveTo::create(duration, toPoint), CallFunc::create([=](){
        callback();
        arrow->removeFromParent();
    }), NULL));
}
Example #4
0
Arrow *Arrow::createArrowByLevel(const std::string &level){
    
    Arrow *newArrow = new (std::nothrow) Arrow(level);
    if (newArrow && newArrow->initArrow()){
        newArrow->autorelease();
        return newArrow;
    }
    
    delete newArrow;
    newArrow = nullptr;
    return nullptr;
    
}
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine)
    {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;

        if (startItems.count() > 0 && endItems.count() > 0 &&
                startItems.first()->type() == Connector::Type &&
                endItems.first()->type() == Connector::Type &&
                startItems.first() != endItems.first())
        {
            Connector *startItem =
                    qgraphicsitem_cast<Connector *>(startItems.first());
            Connector *endItem =
                    qgraphicsitem_cast<Connector *>(endItems.first());
            QDomNode arrowXml =  createArrowXml(startItem,endItem);
            Arrow *arrow = new Arrow(startItem, endItem,arrowXml);

            arrowList.append(arrow);
            arrow->setColor(myLineColor);
            startItem->addArrow(arrow);
            endItem->addArrow(arrow);
            arrow->setZValue(-1000.0);
            addItem(arrow);
            arrow->updatePosition();

        }
    }

    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
    if(myMode == MoveItem)
    {
        DiagramItem* item =(DiagramItem*)itemAt(mouseEvent->scenePos());
        if(item == 0)
            return;
        if(item->type() == DiagramItem::Type)
            {
                item->updatePoz();
                ((DiagramWindow*)parent())->updateXml();
            }
    }
}
Example #6
0
void GridPlot::createNormals(const Plotlet& pl)
{
    if (!normals())
        return;

    Arrow arrow;
    arrow.setQuality(normalQuality());

    Triple /*basev, topv, */ norm;

    int step = resolution();

    const GridData& data = dynamic_cast<const GridData&>(*pl.data);
    const Color& color = *pl.appearance->dataColor();
    double diag = (data.hull().maxVertex-data.hull().minVertex).length() * normalLength();

    arrow.assign(*this);
    arrow.drawBegin();
    for (int i = 0; i <= data.columns() - step; i += step)
    {
        for (int j = 0; j <= data.rows() - step; j += step)
        {
            norm = data.normals[i][j];//topv-basev;
            norm.normalize();
            norm	*= diag;

            const Triple &vert = data.vertices[i][j];
            arrow.setTop(vert+norm);
            arrow.setColor(color.rgba(vert.x, vert.y, vert.z));
            arrow.draw(vert);
        }
    }
    arrow.drawEnd();
}
void SurfacePlot::createNormalsC()
{
	if (!normals() || actualData_p->empty())
		return;

	if (actualDataC_->nodes.size() != actualDataC_->normals.size())
		return;
  Arrow arrow;
  arrow.setQuality(normalQuality());

	Triple basev, topv, norm;	
		
	double diag = (actualData_p->hull().maxVertex-actualData_p->hull().minVertex).length() * normalLength();

  RGBA col;
  arrow.assign(*this);
  arrow.drawBegin();
	for (unsigned i = 0; i != actualDataC_->normals.size(); ++i) 
	{
		basev = actualDataC_->nodes[i];
		topv = basev + actualDataC_->normals[i];
		
			norm = topv-basev;
			norm.normalize();
			norm	*= diag;

      arrow.setTop(basev+norm);
      arrow.setColor((*datacolor_p)(basev.x,basev.y,basev.z));
      arrow.draw(basev);
	}
  arrow.drawEnd();
}
Example #8
0
void Curve::createNormalsG()
{
	if (!normals() || actualDataG_->empty())
		return;

	Arrow arrow;
	arrow.setQuality(normalQuality());

	Triple basev, topv, norm;	
	
	int step = resolution();

	double diag = (actualDataG_->hull().maxVertex-actualDataG_->hull().minVertex).length() * normalLength();

	arrow.assign(*this);
	arrow.drawBegin();
	for (int i = 0; i <= actualDataG_->columns() - step; i += step){
		for (int j = 0; j <= actualDataG_->rows() - step; j += step){
			basev = Triple(actualDataG_->vertices[i][j][0],actualDataG_->vertices[i][j][1],actualDataG_->vertices[i][j][2]);
			topv = Triple(actualDataG_->vertices[i][j][0]+actualDataG_->normals[i][j][0],
							 actualDataG_->vertices[i][j][1]+actualDataG_->normals[i][j][1],
							 actualDataG_->vertices[i][j][2]+actualDataG_->normals[i][j][2]);	
			
			norm = topv-basev;
			norm.normalize();
			norm	*= diag;

			arrow.setTop(basev+norm);
			arrow.setColor((*datacolor_p)(basev.x,basev.y,basev.z));
			arrow.draw(basev);
		}
	}
	arrow.drawEnd();
}
Example #9
0
void OdometryDisplay::updateColor()
{
  QColor color = color_property_->getColor();
  float red   = color.redF();
  float green = color.greenF();
  float blue  = color.blueF();

  D_Arrow::iterator it = arrows_.begin();
  D_Arrow::iterator end = arrows_.end();
  for( ; it != end; ++it )
  {
    Arrow* arrow = *it;
    arrow->setColor( red, green, blue, 1.0f );
  }
  context_->queueRender();
}
Example #10
0
void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (myMode == InsertLine && line != 0) {
        QLineF newLine(line->line().p1(), mouseEvent->scenePos());
        line->setLine(newLine);
    } else if (myMode == MoveItem) {
        if(selectedItems().count())
            if(selectedItems().first()->type()==Arrow::Type) {
                Arrow *item =
                    qgraphicsitem_cast<Arrow *>(selectedItems().first());
                item->setBendPoint(mouseEvent->scenePos().x(), mouseEvent->scenePos().y());
                item->updatePosition();
            }
        QGraphicsScene::mouseMoveEvent(mouseEvent);
    }
}
Example #11
0
Marker::Marker(QObject *parent) :
    QObject(parent)
{
    m_models.push_back(new Pixmap(QPixmap("")));
    m_models.push_back(new QGraphicsWidget(m_models[0]));
    m_models.push_back(new Arrow(QPixmap(":/arrowN.png"), QPixmap(":/arrowNhover.png"), 0, m_models[1]));
    m_models.push_back(new Arrow(QPixmap(":/arrowE.png"), QPixmap(":/arrowEhover.png"), 1, m_models[1]));
    m_models.push_back(new Arrow(QPixmap(":/arrowS.png"), QPixmap(":/arrowShover.png"), 2, m_models[1]));
    m_models.push_back(new Arrow(QPixmap(":/arrowW.png"), QPixmap(":/arrowWhover.png"), 3, m_models[1]));

    for (int i = N; i <= W; ++i)
    {
        Arrow *arrow = static_cast<Arrow *>(m_models[i]);
        arrow->setPos(g_arrowsPos[i - N]);
        connect(arrow, SIGNAL(pressed(int)), this, SIGNAL(moveRequest(int)));
    }
}
Example #12
0
static gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
	if (event->button == 1)
	{
        arrow.y = event->y;
        arrow.set_thrown();
    }
    return TRUE;
}
Example #13
0
Arrow* Arrow::create(b2World* pWorld)
{
	// 'layer' is an autorelease object
	Arrow *pRet = new Arrow();
	if (pRet && pRet->init(pWorld))
	{
		pRet->autorelease();
		return pRet;
	}
	else
	{
		delete pRet;
		pRet = NULL;
		return NULL;
	}

	// return the scene
	return pRet;
}
Example #14
0
void GLWidget::visualizeLayer(int index) {
 //   out << "void GLWidget::visualizeLayer(int index)" << eom;
    assert(m_data);
    assert(index < m_data->getDimension(2));
    m_activeLayer = index;
    m_arrows.clear();
    m_viewMutex.lock();
     for(int i = 0; i < m_data->getDimension(0); i++) {
              for(int j = 0; j < m_data->getDimension(1); j++) {
                  Arrow arrow;
                  arrow.setPosition(i,j,0.0);
                  arrow.setDirectionAndLength(m_data->get4(i,j,m_activeLayer,0),m_data->get4(i,j,m_activeLayer,1),m_data->get4(i,j,m_activeLayer,2));
                  m_arrows.push_back(arrow);
              }
         }
     m_viewMutex.unlock();
    // out << m_arrows.size() << " arrows created." << eom;

}
Example #15
0
void OdometryDisplay::incomingMessage( const nav_msgs::Odometry::ConstPtr& message )
{
  ++messages_received_;

  if( !validateFloats( *message ))
  {
    setStatus( StatusProperty::Error, "Topic", "Message contained invalid floating point values (nans or infs)" );
    return;
  }

  setStatus( StatusProperty::Ok, "Topic", QString::number( messages_received_ ) + " messages received" );

  if( last_used_message_ )
  {
    Ogre::Vector3 last_position(last_used_message_->pose.pose.position.x, last_used_message_->pose.pose.position.y, last_used_message_->pose.pose.position.z);
    Ogre::Vector3 current_position(message->pose.pose.position.x, message->pose.pose.position.y, message->pose.pose.position.z);
    Ogre::Quaternion last_orientation(last_used_message_->pose.pose.orientation.w, last_used_message_->pose.pose.orientation.x, last_used_message_->pose.pose.orientation.y, last_used_message_->pose.pose.orientation.z);
    Ogre::Quaternion current_orientation(message->pose.pose.orientation.w, message->pose.pose.orientation.x, message->pose.pose.orientation.y, message->pose.pose.orientation.z);

    if( (last_position - current_position).length() < position_tolerance_property_->getFloat() &&
        (last_orientation - current_orientation).normalise() < angle_tolerance_property_->getFloat() )
    {
      return;
    }
  }

  Arrow* arrow = new Arrow( scene_manager_, scene_node_, 0.8f, 0.05f, 0.2f, 0.2f );

  transformArrow( message, arrow );

  QColor color = color_property_->getColor();
  arrow->setColor( color.redF(), color.greenF(), color.blueF(), 1.0f );

  float length = length_property_->getFloat();
  Ogre::Vector3 scale( length, length, length );
  arrow->setScale( scale );

  arrows_.push_back( arrow );

  last_used_message_ = message;
  context_->queueRender();
}
Example #16
0
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        while(startItems.count() && startItems.first()->type() != DiagramItem::Type) {
            startItems.removeFirst();
        }
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        while(endItems.count() && endItems.first()->type() != DiagramItem::Type) {
            endItems.removeFirst();
        }
        removeItem(line);
        delete line;

        if (startItems.count() > 0 && endItems.count() > 0)
            if(startItems.first()->type() == DiagramItem::Type &&
                    endItems.first()->type() == DiagramItem::Type &&
                    startItems.first() != endItems.first()) {
                DiagramItem *startItem =
                    qgraphicsitem_cast<DiagramItem *>(startItems.first());
                DiagramItem *endItem =
                    qgraphicsitem_cast<DiagramItem *>(endItems.first());
                if(startItem->diagramType()!=endItem->diagramType()) {
                    Arrow *arrow = new Arrow(startItem, endItem, myItemMenu);
                    if(!startItem->haveSuchArrow(arrow)) {
                        arrow->setColor(myLineColor);
                        startItem->addArrow(arrow);
                        endItem->addArrow(arrow);
                        arrow->setZValue(-1000);
                        addItem(arrow);
                        arrow->updatePosition();
                    }
                }
            }
    }
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
Example #17
0
void Storage::triggerArrow(
    const QPoint &aNewPos,
    const QPoint &anOldPos,
    Arrow &aNewArrow
    )
{
    QLineF aNewLine;
    aNewLine.setLine(
             anOldPos.x(),
             anOldPos.y(),
             aNewPos.x(),
             aNewPos.y()
    );
    aNewArrow.setCoordinates(aNewLine);
    state_ = NewSelection;
    repaint_needed_ = 1;
}
Example #18
0
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data)
{
	sun.draw(cr);
	
	cloud1.draw(cr);
	cloud2.draw(cr);
    cloud3.draw(cr);
    cloud4.draw(cr);
    cloud7.draw(cr);
    cloud8.draw(cr);
    arrow.draw(cr);
    
	balloon.draw(cr);
	balloon.check_hit(arrow);
	balloon2.draw(cr);
	balloon2.check_hit(arrow);
	balloon3.draw(cr);
	balloon3.check_hit(arrow);
	balloon4.draw(cr);
	balloon4.check_hit(arrow);
	
    
    
    bird.draw(cr);
    bird.check_hit(arrow);
    
    
    bush1.draw(cr);
	bush2.draw(cr);
	bush3.draw(cr);
	bush4.draw(cr);
	bush5.draw(cr);
	
	scoreboard.display(cr);
    return FALSE;
}
Example #19
0
JNIEXPORT jlong JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_setPositionY
  (JNIEnv * env, jobject obj, jfloat y, jlong ref){
          Arrow* arrow = (Arrow*) ref;
          arrow->setPositionY(y);
          return (long)arrow;        
  }
Example #20
0
JNIEXPORT jfloat JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_getStrength
  (JNIEnv * env, jobject obj, jlong ref){
          Arrow* arrow = (Arrow*) ref;
          return arrow->getStrength();        
  }
Example #21
0
JNIEXPORT jint JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_getPositionY
  (JNIEnv * env, jobject obj, jlong ref){
          Arrow* arrow = (Arrow*) ref;
          return arrow->getPositionY();
  }
Example #22
0
JNIEXPORT jfloat JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_getTouchRotation
  (JNIEnv * env, jobject obj, jfloat mouseX, jfloat mouseY, jfloat bowCenterX, jfloat bowCenterY, jlong ref){
          Arrow* arrow = (Arrow*) ref;
          return arrow->getTouchRotation(mouseX, mouseY, bowCenterX, bowCenterY); 
  }
Example #23
0
JNIEXPORT jlong JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_update
  (JNIEnv * env, jobject obj, jfloat elapsed,  jlong ref){
          Arrow* arrow = (Arrow*) ref;
          arrow->update(elapsed);
          return (long) arrow;        
  }
Example #24
0
void Player::shoot(int value){
    Arrow* arrow = new Arrow(value);
    arrow->setPos(pos().x(), pos().y());
    scene()->addItem(arrow);
}
Example #25
0
void MainGameScene::endAnimation()
{
    
    CCMenu* retryButton = (CCMenu*)this->getChildByTag(tagRetryButton);
    if(retryButton){
        //retryButton->setOpacity(0);
        retryButton->setEnabled(false);
    }
    
    int moveIndex[25] = {1,2,3,4,5,10,15,20,25,24,23,22,21,16,11,6,7,8,9,14,19,18,17,12,13};
    for(int i = 1; i <= COL_NUM * ROW_NUM; i++){
        CCRotateBy* rotate = CCRotateBy::create(1.5, 360);
        Arrow* arrowObj = (Arrow *)this->getChildByTag(moveIndex[i-1]);
        CCDelayTime* delay = CCDelayTime::create(0.04 * i);
        CCSequence* seq;
        if(i == COL_NUM * ROW_NUM){
             CCCallFunc* funcShowClearDialog = CCCallFunc::create(this, callfunc_selector(MainGameScene::showClearDialog));
            seq = CCSequence::create(delay,rotate, funcShowClearDialog, NULL);
        }else{
            seq = CCSequence::create(delay,rotate,NULL);
        }
        arrowObj->getArrowSprite()->runAction(seq);
    }

    
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite* pC = CCSprite::create("clear_C.png");
    pC->setPosition(ccp(winSize.width * 0.1, winSize.height * 0.6));
    pC->setScale(0.0);
    pC->setZOrder(Z_ORDER_CLEAR_DIALOG);
    pC->runAction(CCSequence::create(CCDelayTime::create(0.1),Animation::clearCharaAction(),NULL));
    this->addChild(pC);
    
    CCSprite* pL = CCSprite::create("clear_L.png");
    pL->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.6));
    pL->setScale(0.0);
    pL->setZOrder(Z_ORDER_CLEAR_DIALOG);
    pL->runAction(CCSequence::create(CCDelayTime::create(0.3),Animation::clearCharaAction(),NULL));
    this->addChild(pL);
    
    CCSprite* pE = CCSprite::create("clear_E.png");
    pE->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.6));
    pE->setScale(0.0);
    pE->setZOrder(Z_ORDER_CLEAR_DIALOG);
    pE->runAction(CCSequence::create(CCDelayTime::create(0.5),Animation::clearCharaAction(),NULL));
    this->addChild(pE);
    
    CCSprite* pA = CCSprite::create("clear_A.png");
    pA->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.6));
    pA->setScale(0.0);
    pA->setZOrder(Z_ORDER_CLEAR_DIALOG);
    pA->runAction(CCSequence::create(CCDelayTime::create(0.7),Animation::clearCharaAction(),NULL));
    this->addChild(pA);
    
    CCSprite* pR = CCSprite::create("clear_R.png");
    pR->setPosition(ccp(winSize.width * 0.9, winSize.height * 0.6));
    pR->setScale(0.0);
    pR->setZOrder(Z_ORDER_CLEAR_DIALOG);
    pR->runAction(CCSequence::create(CCDelayTime::create(0.9),Animation::clearCharaAction(),NULL));
    this->addChild(pR);

    
    
}
Example #26
0
JNIEXPORT jlong JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_startArrow
  (JNIEnv * env, jobject obj, jlong ref){
          Arrow* arrow = (Arrow*) ref;
          arrow->startArrow();
          return (long) arrow;        
  }
Example #27
0
JNIEXPORT jlong JNICALL Java_com_cpgd_arrowshooting3000_components_ArrowProxy_shootArrow
  (JNIEnv * env, jobject obj, jint mouseX, jint mouseY, jfloat bowCenterX, jfloat bowCenterY, jlong ref){
          Arrow* arrow = (Arrow*) ref;
          arrow->shootArrow(mouseX, mouseY, bowCenterX, bowCenterY);
          return (long) arrow;        
  }
Example #28
0
int main(int argc, char *argv[])
{
	Figure f;

	// get some coordinates ready to use in a lot of objects
	
	Coordinate *a = new Coordinate (500,500);
	Coordinate *b = new Coordinate (1500,1500);

	// draw a polyline

	PolyLine *polyline = new PolyLine(a, b);
	polyline->push_back(new Coordinate(2000,1500));
	polyline->setLineStyle(Attributes::Dotted);
	
	// give the polyline arrows
	
	Arrow arr;
	arr.setType(Arrow::ClosedPointed);
	arr.setStyle(Arrow::Filled);

	polyline->setBackwardArrowBool(1);
	polyline->setBackwardArrow(arr);
	
	polyline->setForwardArrowBool(1);
	polyline->setForwardArrow(arr);
	
	// polyline is ready, keep it in the fig
	
	f.push_back(polyline);
	
	// an example box using the same coordinates

	Box *box = new Box(a, b);
	box->setThickness(2);
	f.push_back(box);
	
	// an ellipse in that box

	RadiiEllipse *re = new RadiiEllipse(new Coordinate(1000, 1000), new Coordinate(500, 200));
	f.push_back(re);
	
	// another ellipse in that box

	DiameterEllipse *de = new DiameterEllipse(new Coordinate(500, 800), new Coordinate(1500, 1200));
	f.push_back(de);
	
	// a circle defined by a radius, in the box

	RadiusCircle *rc = new RadiusCircle(new Coordinate(1000, 1000), 500);
	f.push_back(rc);
	
	// a circle defined by two points defining its radius

	DiameterCircle *dc = new DiameterCircle(a, b);
	f.push_back(dc);
	
	// some text

	Text* text = new Text(new Coordinate(1900, 900), "fig++");
	text->setFontSize(50);
	f.push_back(text);

	// an arc defined by its three defining points
	// first point comes first

	Arc* arc = new Arc(new Coordinate(1000, 1000), new Coordinate(2000, 1000), new Coordinate(2000, 2000));
	f.push_back(arc);
	
	// this is what's useful: putting something on an arbitrary place

	for (float x = 0; x <= 314; x=x+19.625) {
		PolyLine *l = 
			new PolyLine( 
				new Coordinate(
					(int)(1500.0+500.0*cos(x/100)),
					(int)(1500.0+500.0*sin(x/100))
				),
				new Coordinate(
					(int)(1500.0+1000.0*cos(x/100)),
					(int)(1500.0+1000.0*sin(x/100))
				)
			);
		l->setForwardArrowBool(1);
		arr.setType(Arrow::ClosedIntended);
		l->setForwardArrow(arr);
		f.push_back(l);
	}
	
	// a vector of coordinates

	std::vector<Coordinate *> vc;

	vc.push_back( new Coordinate (2500, 500) );
	vc.push_back( new Coordinate (3000, 500) );
	vc.push_back( new Coordinate (3000, 1000) );
	vc.push_back( new Coordinate (3500, 1000) );
	vc.push_back( new Coordinate (3500, 1500) );
	vc.push_back( new Coordinate (3000, 1500) );
	vc.push_back( new Coordinate (3000, 2000) );
	vc.push_back( new Coordinate (2500, 2000) );
	vc.push_back( new Coordinate (2500, 1500) );
	vc.push_back( new Coordinate (2000, 1500) );
	vc.push_back( new Coordinate (2000, 1000) );
	vc.push_back( new Coordinate (2500, 1000) );
	
	// the vector as a polyline

	Polygon *pl = new Polygon ();
	for (std::vector<Coordinate *>::iterator i = vc.begin(); i != vc.end(); i++)
		pl->push_back(*i);
	f.push_back(pl);
	
	// two possible splines defined by the vector

	Spline *spline1 = new Spline();
	Spline *spline2 = new Spline();
	for (std::vector<Coordinate *>::iterator i = vc.begin(); i != vc.end(); i++) {
		spline1->push_back( new SplineCoordinate(*i, -1) ); // interpolated
		spline2->push_back( new SplineCoordinate(*i, 1) ); //approximated
	}
	spline1->setSubType(Spline::Closed);
	f.push_back(spline1);
	spline2->setSubType(Spline::Closed);
	f.push_back(spline2);
	
	// print the file to the standard out

	std::cout << f;

	return EXIT_SUCCESS;
}
Example #29
0
void MainGameScene::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{

    
    //タップポイント取得
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCPoint touchPoint = pDirector->convertToGL(pTouch->getLocationInView());
    
    if(endFlag){
        
    }else{
        
       
        
        for(int i = 1; i <= COL_NUM * ROW_NUM; i++){
            Arrow* arrowObj = (Arrow *)this->getChildByTag(i);
            
            if(!arrowObj){
                return;
            }
            
            //タッチ判定
            CCRect arrowRect = arrowObj->getArrowSprite()->boundingBox();
            if(arrowRect.containsPoint(touchPoint)){
                
                //タッチ数を更新して表示
                if(totalGameCount < 99){
                    totalGameCount++;
                }
                
                showGameCountLabel();
                
                //z-indexあげる
                arrowObj->setZOrder(Z_ORDER_ARROW);
                
                setTouchEnabled(false);
                
                //タッチした時の内部処理
                arrowObj->onTouchArrow();
                
                
                bool reverseFlag;
                //左端かつ左向き
                if(i % COL_NUM == 1 && arrowObj->getDirection() == 3){
                    reverseFlag = false;
                    
                    //右端かつ右向き
                }else if (i % COL_NUM == 0 && arrowObj->getDirection() == 1){
                    reverseFlag = false;
                    
                    //下端かつ下向き
                }else if (i <= COL_NUM && arrowObj->getDirection() == 2){
                    reverseFlag = false;
                    
                    //上端かつ上向き
                }else if (i <= COL_NUM * ROW_NUM && i > COL_NUM * (ROW_NUM - 1) && arrowObj->getDirection() == 0 ){
                    reverseFlag = false;
                    
                    //反転する場合
                }else{
                    reverseFlag = true;
                    
                }
                
                int addIndex;
                switch (arrowObj->getDirection()) {
                    case 0: //上
                        addIndex = ROW_NUM;break;
                    case 1: //右
                        addIndex = 1;break;
                    case 2: //下
                        addIndex = -ROW_NUM;break;
                    case 3: //左
                        addIndex = -1;break;
                }
                
                int nextIndex = i + addIndex;
                Arrow* nextArrowObj;
                if(nextIndex > 0) {
                   nextArrowObj = (Arrow *)this->getChildByTag(nextIndex);
                }
                
                if(!nextArrowObj){
                    reverseFlag = false;
                }
                
                
                CCCallFunc* funcReverseArrow = CCCallFunc::create(arrowObj, callfunc_selector(Arrow::reverseArrow));
                
                CCRotateBy* rotate = CCRotateBy::create(0.3, 90);
                
                CCScaleTo* scaleUp = CCScaleTo::create( 0.15,1.8);
                CCScaleTo* scaleDown = CCScaleTo::create(0.15,1.0);
                CCSequence* seqScale = CCSequence::createWithTwoActions(CCEaseInOut::create(scaleUp, 2), CCEaseInOut::create(scaleDown, 2));
                
                CCSpawn* spaRotateAndScale = CCSpawn::createWithTwoActions(rotate, seqScale);
                
                CCDelayTime* delay = CCDelayTime::create(0.1);
                CCCallFunc* funcEndJudge = CCCallFunc::create(this, callfunc_selector(MainGameScene::endJudgemnet));
                
                if(reverseFlag){
                    
                    CCCallFunc* funcReverseNextArrow = CCCallFunc::create(nextArrowObj, callfunc_selector(Arrow::reverseArrow));
                    arrowObj->getArrowSprite()->runAction(CCSequence::create(spaRotateAndScale, delay, funcReverseArrow, funcReverseNextArrow, funcEndJudge, NULL));
                }else{
                    arrowObj->getArrowSprite()->runAction(CCSequence::create(spaRotateAndScale, delay, funcReverseArrow, funcEndJudge, NULL));
                }
                
                if(arrowObj->getArrowSprite() == arrowObj->getArrowOnSprite()){
                    //Onの場合
                    arrowObj->getArrowOffSprite()->setRotation(arrowObj->getDirection() * 90);
                }else if(arrowObj->getArrowSprite() == arrowObj->getArrowOffSprite()){
                    //Offの場合
                    arrowObj->getArrowOnSprite()->setRotation(arrowObj->getDirection() * 90);
                }
                
            }
            
        }
        
    }
}
Example #30
0
int ArcherGuy::update(ObjectHolder *objHolder, GameProperties *gameProps, AudioPlayer *audioPlayer, Controller *contrlr, float delta)
{
	if (firingArrow == 1)
	{
		fireArrowCount += delta;
		if (dir_facing & DIR_LEFT)
		{
			if (cur_anim != ANIM_ARCHER_GUY_FIRE_LEFT)
				setAnimation(gameProps->getAnimHolder(), ANIM_ARCHER_GUY_FIRE_LEFT);
		}
		if (dir_facing & DIR_RIGHT)
		{
			if (cur_anim != ANIM_ARCHER_GUY_FIRE_RIGHT)
				setAnimation(gameProps->getAnimHolder(), ANIM_ARCHER_GUY_FIRE_RIGHT);
		}
		if (fireArrowCount > ARROW_GUY_FIRE_COOLDOWN)
		{
			setAnimation(gameProps->getAnimHolder(), ANIM_ARCHER_GUY_WALK_RIGHT);
			fireArrowCount = 0;
			firingArrow = 0;
			Arrow *bl = new Arrow();
			bl->setShooter(this);
			bl->setDirection(dir_facing);
			bl->load(gameProps->getResLoader(), gameProps->getAnimHolder());
			bl->setPos(getPosition()->getX(), getPosition()->getY());
			gameProps->addObject(bl);
		}
	}
	if (firingArrow == 0)
	{
		fireArrowCooldown += delta;
		Pos2 posDown;
		posDown.set(getPosition());
		posDown.addY(size->getY()+.3);
		Pos2 posAhead;
		posAhead.set(getPosition());
		posAhead.addY(size->getY()/2);
		if (dir_facing & DIR_LEFT)
		{
			posDown.addX(-.2);
			posAhead.addX(-.7);
		}else
		if (dir_facing & DIR_RIGHT)
		{
			posDown.addX(size->getX()+.2);
			posAhead.addX(size->getX()+.7);
		}
		if (BaseObject::checkExists(objHolder, &posDown, TYP_SOLID) == 0 ||
			BaseObject::checkExists(objHolder, &posAhead, TYP_SOLID | TYP_KILLS) == 1)
		{
			if (dir_facing & DIR_LEFT)
				dir_facing = DIR_RIGHT;
			else if (dir_facing & DIR_RIGHT)
				dir_facing = DIR_LEFT;
		}
		if (dir_facing & DIR_LEFT)
		{
			if (cur_anim != ANIM_ARCHER_GUY_WALK_LEFT)
				setAnimation(gameProps->getAnimHolder(), ANIM_ARCHER_GUY_WALK_LEFT);
			vel->setX(-1);
		}
		if (dir_facing & DIR_RIGHT)
		{
			if (cur_anim != ANIM_ARCHER_GUY_WALK_RIGHT)
				setAnimation(gameProps->getAnimHolder(), ANIM_ARCHER_GUY_WALK_RIGHT);
			vel->setX(1);
		}
		if (Guy::checkDeath(gameProps) == 1)
			die(NULL);
	}
	return BaseObject::update(objHolder, gameProps, audioPlayer, contrlr, delta);
}