Note that there are some explanatory texts on larger screens.

plurals
  1. PO2D arrary of enemies crashes on creation
    primarykey
    data
    text
    <p>Hi guys I'm having a problem in my Ogre problem. I'm not sure if this is the best place to ask this but I may as well. Here is the sample of the code I made in order to create a 2D array of enemies(for a space invaders game</p> <pre><code> for(int i = 0; i &lt; 5; i++) //Manages the YPOS coordinate of the enemy { for(int j = 0; j &lt; 5; j++) //Manages the YPOS coordinate of the enemy { stringstream ss; ss &lt;&lt; j; std::string pos = ss.str(); ss.clear(); ss &lt;&lt; i; pos += "," + ss.str(); std::string enemyName = "Enemy " + pos; Ogre::Entity * enemyEnt = mSceneMgr-&gt;createEntity(enemyName, "razor.mesh"); Ogre::SceneNode *node1 = mSceneMgr-&gt;getRootSceneNode()-&gt;createChildSceneNode (enemyName+"ParentNode"); Ogre::SceneNode *node2 = node1-&gt;createChildSceneNode(enemyName+"Node"); enemyEnt-&gt;setMaterialName("Examples/Chrome"); mSceneMgr-&gt;getSceneNode(enemyName+"Node")-&gt;attachObject(ent); int multiplier = 100; if(j &lt; 3) { multiplier *= -1; } if(j == 3) { multiplier = 0; } Vector3 initialPos; initialPos.x = (j+1) * multiplier; initialPos.y = 0; initialPos.z = 3000 - ((i+1) * multiplier); enemyVec.push_back(new Enemy(mSceneMgr,node2, initialPos, j, i, 200 )); } } enem-&gt;setEnemies(enemyVec); } </code></pre> <p>The following is there error I'm getting</p> <p>Unhandled exception at 0x59a6ad4e (msvcp100d.dll) in C00146012 Project - 3D Space Invaders.exe: 0xC0000005: Access violation reading location 0xcccccd24.</p> <p>When debugging it brings it to this segment of code in xutility</p> <pre><code>#if _ITERATOR_DEBUG_LEVEL == 2 if (_Myproxy != 0) { // proxy allocated, drain it _Lockit _Lock(_LOCK_DEBUG); for (_Iterator_base12 **_Pnext = &amp;_Myproxy-&gt;_Myfirstiter; *_Pnext != 0; *_Pnext = (*_Pnext)-&gt;_Mynextiter) (*_Pnext)-&gt;_Myproxy = 0; _Myproxy-&gt;_Myfirstiter = 0; } #endif /* _ITERATOR_DEBUG_LEVEL == 2 */ </code></pre> <p>However I know the error is in the line: </p> <pre><code>enem-&gt;setEnemies(enemyVec); </code></pre> <p>Any and all help would be greatly appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload