chingu icon indicating copy to clipboard operation
chingu copied to clipboard

Klass.empty?

Open ghost opened this issue 10 years ago • 2 comments

Hi, I have a question about game objects. How can I know if exist objects of a particular class? That is, I need to do something like: if Enemy.empty? # logic if not objects of Enemy class. end Could create an Array with all the enemies but do not want to create variables if not necessary. I tried with "Array(Enemy).empty?" but nothing.

Another question is that when I load a font, the console throws me this: ERROR: failed to open './resources/8_bit_madness.ttf' ERROR: CreateFile failed

The code is this: @ text_starge = Text.create (: text => "# {@ starge STARGE}",: size => 25,: font => "resources/8_bit_madness.ttf")

Any help?. Thanks!

ghost avatar Mar 03 '14 00:03 ghost

Did you try Enemy.all ?

About the font-error: Under the hood Chingu uses Gosu::Font.new to draw text .. so a font-error most likely comes from there. You might want to check your paths .. but if the path is 100% correct, you need to check into why Gosu doesn't want to open that font. Try open it with pure Gosu for example.

ippa avatar Sep 06 '14 19:09 ippa

I had a small mess in the organization of the directories and therefore Chingu did not recognize me the assets correctly. Indeed, Enemy.all fix everything, is easy to manipulate the objects using arrays. Thank!!

ghost avatar Sep 22 '14 17:09 ghost