Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7829069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:36:17+00:00 2026-06-02T10:36:17+00:00

I’m trying to create a grid for a game using the Moai SDK. Each

  • 0

I’m trying to create a grid for a game using the Moai SDK. Each tile in the grid should have the ability to be filled with a color.

So actually I have two questions:

  • What is the best way to build a grid using Moai
  • How can I fill each tile individually with a color

The grid

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:36:18+00:00Added an answer on June 2, 2026 at 10:36 am

    What is the best way to build a grid using Moai

    Moai has an object for creating grids: MOAIGrid. Using the framework’s
    jargon, you create a grid and give it a deck. Then you attach it to a prop and
    add the prop to a layer. (That layer also needs a viewport which is attached
    to a window.)

    How can I fill each tile individually with a color

    A Moai deck is an image or collection of images. If you wanted your
    tiles to be different colors then you would create a deck with images of the
    square in those colors.

    Example

    This code will create a 4×4 grid in a window:

    -- Open the window and create a viewport
    MOAISim.openWindow("Example", 512, 512)
    viewport = MOAIViewport.new()
    viewport:setSize(512, 512)
    viewport:setScale(512, 512)
    
    -- Create a layer
    layer = MOAILayer2D.new()
    layer:setViewport(viewport)
    MOAISim.pushRenderPass(layer)
    
    -- Create a 4x4 grid of 64x64px squares
    grid = MOAIGrid.new()
    grid:initGrid(4, 4, 64)
    grid:setRow(1, 1, 1, 1, 1)
    grid:setRow(2, 1, 1, 1, 1)
    grid:setRow(3, 1, 1, 1, 1)
    grid:setRow(4, 1, 1, 1, 1)
    
    -- Load the image file
    deck = MOAITileDeck2D.new()
    deck:setTexture("squares.png")
    deck:setSize(2, 2)
    
    -- Make a prop with that grid and image set
    prop = MOAIProp2D.new()
    prop:setDeck(deck)
    prop:setGrid(grid)
    prop:setLoc(-256, -256)
    
    -- Add it to the layer so it will be rendered
    layer:insertProp(prop)
    

    After that, if you want to change the color of a specific cell, use the
    setTile method to choose which item in the deck that cell uses.

    -- Change the color of cell 1,1 to the second item in the deck
    grid:setTile(1, 1, 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.