Note that there are some explanatory texts on larger screens.

plurals
  1. POCall an update method for all instances of a class in objective c?
    primarykey
    data
    text
    <p>Lost in a sea of confusion, I really hope someone can help me here. This question regards how to use object oriented programming correctly, something I can't seem to do.</p> <p>I am also sharing my train of thought, if anything seems flawed please tell me.</p> <p><em>WHAT I WANT TO DO:</em></p> <p>I am making a SpriteKit game, and like all games, there is logic that needs to be run every frame. As of now, the only way I can run something every frame is using my SKScene's update method. </p> <p>A game has players, enemies, bullets, obstacles, collectibles, you name it. Each one needs to update every frame to handle the rapidly changing environment. lets take 'bullets' for example. I have a 'bullet' class in my game. The bullet has logic that needs to be run every frame. I have an 'update' method in my class to handle this logic, but I cannot find a good way to <strong>run this method every frame for all the instances of bullet.</strong></p> <p>I have attempted this many ways and all are hideous and inefficient. I have, on numerous occasions, misused to beauty of OOP to the point of sloppy code that barely achieves the task at hand.</p> <p>I need something like an <code>updateAllBullets</code> method, but even if that existed, I would then need to run an <code>updateAllEnemies</code>, <code>updateAllItems</code>, and that wouldn't even handle the subclasses of those game objects. This leads me to believe that I am misguided in how I am making this game. I am really hoping someone can work with me to get an efficient system in place, even if it means redesigning everything. I am not asking for code, of course, as I have not even provided any (I can upon request if its relevant), but I am instead asking for OOP concepts that I should be using.</p> <p>I will gladly clarify anything you have as fast as I can. Cheers.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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