Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

358 Neutral

About Elit3d

  • Rank
  1. I really appreciate the help, great community here
  2. Ah great, many thanks! I can see my mistake now, I'm so stupid, I'm supposed to create a new instance of the object otherwise the position is going to be transferred to each pickup this is now my code: pickups = new Pickup("images/icon-power.png", sf::Vector2f(obj[i].rect.left, obj[i].rect.top)); if (bSpawnNoMore == false) pickupVector.push_back(pickups);
  3. Pickup::Pickup(std::string imgpath) { texture.loadFromFile(imgpath); sprite.setTexture(texture); } its just a simple entity class really that lets me set the pickup sprite entity class: class Entity { public: sf::Sprite sprite; sf::Texture texture; }; basically, when the level loads, depending on how many "item" points there are on the parsed map, will spawn the correct amount of items (i know how to spawn the certain cap of items already) on each grid spot as shown, like Alberth said, its something to do with the sprite position updating to the last position passed to sprite.setPosition
  4. What is the best way to deal with this?
  5. So I am trying to get an item to spawn on specific locations. I am using a xml parser to get the objects name and location (solid walls, start point, end point and item spawn points). It will only spawn on the last location and totally avoids the first. Anyway here is my code that I have so far: the problem: The spawn locations i want to place on: The code: for (int i = 0; i < obj.size(); i++) { if (obj[i].name == "item") { pickups->sprite.setPosition(obj[i].rect.left, obj[i].rect.top); pickupVector.push_back(pickups); } } so I want to spawn it on the first one location, then push it onto the array, then spawn the next one and put on array and so on..
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!