-
hamletLikes 0Problem Description
/ Position of Codes
Vec2 firstposition = Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-2.5,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);Vec2 secondposition = Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-4.1,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);Vec2 thirdposition = Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-11.8,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);Vec2 fourthposition = Vec2(frontdisplay->getPositionX()-frontdisplay->getContentSize().width/11.7,
frontdisplay->getPositionY()+ frontdisplay->getContentSize().height/-26);Vec2 fifthposition = Vec2(frontdisplay->getPositionX()-frontdisplay->getContentSize().width/4.1,
frontdisplay->getPositionY()+ frontdisplay->getContentSize().height/-26);
Vec2 sixthposition = Vec2(frontdisplay->getPositionX()-frontdisplay->getContentSize().width/2.5,
frontdisplay->getPositionY()+ frontdisplay->getContentSize().height/-26);Vec2 positionsArray[6];
positionsArray[0] = firstposition;
positionsArray[1] = secondposition;
positionsArray[2] = thirdposition;
positionsArray[3] = fourthposition;
positionsArray[4] = fifthposition;
positionsArray[5] = sixthposition;
this->_position;std::vector<cocos2d::Sprite*>_position;
auto Signal1=Sprite::createWithSpriteFrameName("signal1.png");
Signal1->setTag(0);
Signal1->_position.pushBack(Signal1);
the build say sucessfull but i can not see the Sprite in my Displayscreen
-
Sonar Systems adminLikes 0
Do you know if the sprite is created and displayed successfully when it’s a single sprite?
-
hamletLikes 0
Excuse for delay , if i add Signal1->setPosition(positionsArray[0]); Show the Sprite ,but i thing that this is not correct, the vector muss make the pushback with are the vector in the array without add setPosition.
Note:
this is part of one layer that is floating inside one Scene.
-
Sonar Systems adminLikes 0
But can you get a single sprite on its own working?
-
hamletLikes 0
if i am not add the position not,
for example
auto Signal1=Sprite::createWithSpriteFrameName("signal1.png");
Signal1->setposition(Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-2.5,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);layer->addchild(Signal1)
can get Signal1, but in vector _position.pushBack(Signal1) not
i think the array (positionarray[6]) dont acept the las line (this->_position;
-
Sonar Systems adminLikes 0
?????
-
hamletLikes 0
yes thas i try to say is i make a simple sprite with sprite frame i can do it
-
hamletLikes 0
hello now i tryed with http://www.sonarlearning.co.uk/coursepage.php?topic=desktop&course=cplusplus in cocos2d exactly like is here , say successfull but dont show the integrer value when i try to rum the app
-
Sonar Systems adminLikes 0
Which integer value and where doesn’t it show?
-
hamletLikes 0
in the example # 76 of c++ series .
std::vector <int>myVector;
myVector.push_back(23);
myVector.push_back(25);
myvector.push_back(13);
std::cout<<myVector[0]<<std::endl;
this dont show the number 23 in cocos2d too
-
hamletLikes 0
but in c++ 2010 express is 23 the output
-
Sonar Systems adminLikes 0
What does it show?
-
hamletLikes 0
only show backgrounddisplay and frontdisplay Sprite
this is the hole code .
visibleSize = Director::getInstance( )->getVisibleSize( );
Vec2 origin = Director::getInstance( )->getVisibleOrigin( );auto backgrounddisplay=Sprite::createWithSpriteFrameName("backgrounddisplay.png");
backgrounddisplay->setPosition(Vec2(visibleSize.width/2 +origin.x, visibleSize.height/2+origin.y));
layer->addChild(backgrounddisplay,-2);
auto frontdisplay=Sprite::createWithSpriteFrameName("frontdisplay.png");
frontdisplay->setPosition(Vec2(visibleSize.width/2 +origin.x, visibleSize.height/2+origin.y));
layer->addChild(frontdisplay,2);// Position of Codes
Vec2 firstposition = Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-2.5,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);Vec2 secondposition = Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-4.1,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);Vec2 thirdposition = Vec2(frontdisplay->getPositionX()- frontdisplay->getContentSize().width/-11.8,
frontdisplay->getPositionY()+frontdisplay->getContentSize().height/-26);Vec2 fourthposition = Vec2(frontdisplay->getPositionX()-frontdisplay->getContentSize().width/11.7,
frontdisplay->getPositionY()+ frontdisplay->getContentSize().height/-26);Vec2 fifthposition = Vec2(frontdisplay->getPositionX()-frontdisplay->getContentSize().width/4.1,
frontdisplay->getPositionY()+ frontdisplay->getContentSize().height/-26);
Vec2 sixthposition = Vec2(frontdisplay->getPositionX()-frontdisplay->getContentSize().width/2.5,
frontdisplay->getPositionY()+ frontdisplay->getContentSize().height/-26);Vec2 positions[6];
positions[0] = firstposition;
positions[1] = secondposition;
positions[2] = thirdposition;
positions[3] = fourthposition;
positions[4] = fifthposition;
positions[5] = sixthposition;
this->_positions;
std::vector<cocos2d::Sprite*>_positions(6);auto Signal1=Sprite::createWithSpriteFrameName("signal1.png");
Signal1->setTag(0);
this->_positions.pushBack(Signal1);
std::cout<<_positions[0]<<std::endl;
-
Sonar Systems adminLikes 0
Use create instead of createWithSpriteFrameName
-
hamletLikes 0
ok i was made this before and dont show the sprite Signal1
-
hamletLikes 0
might you make a good example with vector in cocos2d please
-
Sonar Systems adminLikes 0
Does the create method work instead?
-
hamletLikes 0
only a short example how can use the vector because is good directly en c++ series example 76 of the serie i can make it in c++ but not in cocos2d i dont know why
-
Sonar Systems adminLikes 0
But i’m asking can you get a regular sprite to work in Cocos2d-x, if not you need to learn that first.
-
hamletLikes 0
yes i can make it :
auto Namesprite=Sprite::create(“sprite.png”);
Namesprite->setPosition(0f.0f);
this->addchilld(Namesprite);
-
Sonar Systems adminLikes 0
Does it show up without any errors?
-
hamletLikes 0
this show without erros
-
Sonar Systems adminLikes 0
-
hamletLikes 0
thank you , i will make this examples
-
Sonar Systems adminLikes 0
Coolio, let us know if you have any queries.
Login to reply