bearkin333 Posted July 23, 2015 Share Posted July 23, 2015 Hello all, I'm working on a little pet project of mine called Whitesmith, and I've run into kind of a major stumbling block. A big part of the game are craftable weapons that the player can equip. The last time I was coding, I was using C++, and now I can't picture a way to implement the weapons without using some kind of object. I've considered extending the Sprite class, but that seems unwieldy for what I'm trying to use it for.Any assistance with this would be greatly appreciated.--Cary Reese Link to comment Share on other sites More sharing options...
Skeptron Posted July 23, 2015 Share Posted July 23, 2015 Using Object-oriented designs is very suitable for a game project, even with JS or Phaser! See these examples for Sprite inheritance : http://phaser.io/examples/v2/sprites/extending-sprite-demo-1, http://phaser.io/examples/v2/sprites/extending-sprite-demo-2 Tilde 1 Link to comment Share on other sites More sharing options...
gianthead Posted July 23, 2015 Share Posted July 23, 2015 A sprite is just one representation of your game object. So instead of coupling it to the weapon itself, why not just create a brand new object for your weapon? and then add a sprite as one of its member variables to represent it? This would give you the flexibility of say using multiple sprites should you want to represent your weapon that way. Or maybe using text if you want to render your game in a console. Link to comment Share on other sites More sharing options...
bearkin333 Posted July 24, 2015 Author Share Posted July 24, 2015 Ah, gianthead, that's a fantastic idea! I don't know why, but for some reason I was just under the impression that I couldn't make an object on my own. That really helps me move forwards. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts