James Dunn
James Dunn

Reputation: 192

Loading an image from a subdirectory in a gem

I used bundler to create a new gem, and I'm playing with rubygame. So far, it's going OK, except I can't get images on the Surface because I can't figure out what the path is to my images directory. I know it's sad, but I'm sorta used to Rails loading my images for me.

The full path to the image is: /usr/local/src/jewel_thief/lib/jewel_thief/images/player.png.

and I'm trying to use it in:

/usr/local/src/jewel_thief/lib/jewel_thief/player.rb (view source)

What am I doing wrong?

Upvotes: 0

Views: 92

Answers (2)

Salil
Salil

Reputation: 47512

Change

@image = Surface.load 'jewel_thief/images/player.png'

To

@image = Surface.load '/jewel_thief/images/player.png'

I think following also work

@image = Surface.load '/jewel_thief/lib/jewel_thief/images/player.png'

Upvotes: 1

James Dunn
James Dunn

Reputation: 192

The path ended up being this:

@image = Surface.load 'lib/jewel_thief/images/player.png'

Finally, after being stumped for hours. Thanks for the help though! Really.

Upvotes: 0

Related Questions