We're going to insert a background to our screen:
The first thing we're going to do is display a background. This should be pretty easy for you right now. A good idea will be searching www.opengameart.org for a suitable background. That's what has been done in the code for this chapter, and you'll find a background in there.
Let's add the definition. If you're using an image other than the one provided in the book's code, just go ahead and change the dimensions and filename (this code should go inside
resources_definition
):background = { type = RESOURCE_TYPE_IMAGE, fileName = 'background/wizardtower.png', width = 1000, height = 700 },
Now, let's add a line at the bottom of the
initialize ()
method to load the background:self:loadBackground ()
And now let's define that method:
function Game:loadBackground() self.background = {} self.background.deck = ResourceManager:get('background') local prop = MOAIProp2D.new () prop:setDeck (self.background.deck) ...