Gameboard Interaction

Hey Everybody,

The game that I am working on has an image that I have placed on it that is the actual gameboard. So I have a screen that opens with a black background and the actual gameboard is on the screen to the bottom right. It does not fill the entire screen which is the way I want it. I have blocks that I want to drag on top of the board and place in certain spaces. I have coded my blocks where I can drag them but when I drag them to the board they go behind the board. What do I have to do to the gameboard.png image to make the blocks interact with it? Do I have to change the bodytype of the board. I know I made the floor on my game static so if a block falls on it, it will not fall through but I am interacting with the gameboard differently. Any help would be appreciated.

Michelle [import]uid: 72372 topic_id: 12215 reply_id: 312215[/import]

You may have already seen my earlier message, but try this;

[lua]gameboard:toBack()[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 12215 reply_id: 44564[/import]

Peach,

That worked but it also took it behind my background also. So I can see my background and my blocks but not the gameboard now.

Michelle [import]uid: 72372 topic_id: 12215 reply_id: 44570[/import]

Corona takes a painters aproach for display objects meaning the first object you declare in your code will be below everything and the last object declared will be on top of everything. Here is a code example:
[lua]-- This image will be behind anything declared below it
local background = display.newImage(“background.png”)
– This image will be in front of the background but behind the gamepiece
local gameboard = display.newImage(“gameboard.png”)
– This image will be in front of everything declared above it
local gamepiece = display.newImage(“gamepiece.png”)[/lua] [import]uid: 27965 topic_id: 12215 reply_id: 44572[/import]

THAT WORKED PERFECTLY!!!

Now since they work like that. The line that you listed as gamepiece above. I have 16 of those gamepieces that will move around the gameboard. I think since I loaded them one at at time they are of course one in front of the other. When some of them come near the other they shift them out of place. How do I have them where I can move them around the board without impacting each other? For instance the last two I put on the board the orange and green ones only impact each other. The green one which was the last to go on the board doesn’t impact anything. It’s like you say, the way they were placed. How do I fix that? [import]uid: 72372 topic_id: 12215 reply_id: 44577[/import]

I’m guessing you’re using physics for the game pieces? If you don’t need to use physics then just don’t add physics bodies to the pieces. If you need to use physics and don’t want the pieces interacting with each other then you can set the body type on all of them to “static”. I copied the text below directly from the physics documentation.

•static bodies don’t move, and don’t interact with each other; examples of static objects would include the ground, or the walls of a pinball machine.
•dynamic bodies are affected by gravity and collisions with the other body types.
•kinematic objects are affected by forces but not by gravity, so you should generally set draggable objects to “kinematic”, at least for the duration of the drag event.

Here is a link to the physics bodies docs.
http://developer.anscamobile.com/content/game-edition-physics-bodies [import]uid: 27965 topic_id: 12215 reply_id: 44596[/import]