Question

I'm trying to call resources (images, for example.) from my website to avoid constant updates. Thus far, I've tried just using this:

 @sprite.bitmap = Bitmap.new("http://www.minscandboo.com/minscgame/001-Title01.jpg")

But, this just gives "File not found error". What is the correct method for achieving this?

Was it helpful?

Solution

Try using Net::HTTP to get a local file first:

require 'net/http'

Net::HTTP.start("minscandboo.com") { |http|
  resp = http.get("/miscgame/001-Title01.jpg")
  open("local-game-image.jpg", "wb") { |file|
    file.write(resp.body)
   }
}

# ...

@sprite.bitmap = Bitmap.new("local-game-image.jpg")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top