[Resolved] how to hide character behind the wall

hi friends

I am developing a game in which i wanted to hide the sprite sheet behind the wall.

The situation is such that character (sprite sheet) is moving and once it comes near wall it should be behind the wall. but in my coding character is coming on top of the wall.

hoping for your reply

Thanks & Regards
Varun [import]uid: 130269 topic_id: 23717 reply_id: 323717[/import]

wall:toFront()

Try that, should move wall in front of your player.

You could also simply add the wall after the player in your code.

Peach :slight_smile: [import]uid: 52491 topic_id: 23717 reply_id: 95367[/import]

i did changes in coding but putting it wall after the player code but did not got the result [import]uid: 130269 topic_id: 23717 reply_id: 95370[/import]

Peach is right there, just put the wall after the player in the same display group, so it gets a higher z-index. [import]uid: 90610 topic_id: 23717 reply_id: 95381[/import]

If you still can’t figure it out post some code and we can try to advise further, but that will do it - just make sure to account for the display group as dingo mentioned :slight_smile: [import]uid: 52491 topic_id: 23717 reply_id: 95395[/import]

this is the code in this i wanna display sprite sheet behind the land 1

local land_04 = display.newImage(“images/land_04.png”)
land_04:setReferencePoint(display.CenterReferencePoint)
land_04.x = 0
land_04.y = _H/2 + 45
localGroup:insert(land_04)

local land_03 = display.newImage(“images/land_03.png”)
land_03:setReferencePoint(display.CenterReferencePoint)
land_03.x = _W/2 - 40
land_03.y = _H/2 + 110
localGroup:insert(land_03)

local land_02 = display.newImage(“images/land_02.png”)
land_02:setReferencePoint(display.CenterReferencePoint)
land_02.x = _W/2 - 60
land_02.y = _H/2 + 120
localGroup:insert(land_02)

local function my(e)
require “sprite”

local abc5 = sprite.newSpriteSheetFromData( “char.png”, require(“char”).getSpriteSheetData() )

local spriteSet5 = sprite.newSpriteSet(abc5,1,5)

sprite.add(spriteSet5,“xyz5”,1,5,800,0)

local spriteInstance5 = sprite.newSprite(spriteSet5)

local Trajectory = require( “dmc_trajectory” )

local begin_point, end_point = { 10, 225 }, { 325, 300 }

Trajectory.move( spriteInstance5, { time=10000, pBegin=begin_point, pEnd=end_point, height=35, rotate = true } )
spriteInstance5:setReferencePoint(display.BottomRightReferencePoint)
spriteInstance5.type = “sprite”
spriteInstance5:scale(1,1)
spriteInstance5:prepare(“xyz5”)
physics.addBody(spriteInstance5, “kinematic” )
spriteInstance5.myName = “sprite5”
spriteInstance5:play()
localGroup:insert(spriteInstance5)

local function nexr5(e)
require “sprite”

local abc5 = sprite.newSpriteSheetFromData( “char.png”, require(“char”).getSpriteSheetData() )

local spriteSet5 = sprite.newSpriteSet(abc5,1,5)

sprite.add(spriteSet5,“xyz5”,1,5,800,0)

local spriteInstance5 = sprite.newSprite(spriteSet5)

local Trajectory = require( “dmc_trajectory” )

local begin_point, end_point = { 10, 225 }, { 325, 300 }

Trajectory.move( spriteInstance5, { time=10000, pBegin=begin_point, pEnd=end_point, height=35, rotate = true } )
spriteInstance5:setReferencePoint(display.BottomRightReferencePoint)
spriteInstance5.type = “sprite”
spriteInstance5:scale(1,1)
spriteInstance5:prepare(“xyz5”)
physics.addBody(spriteInstance5, “kinematic” )
spriteInstance5.myName = “sprite5”
spriteInstance5:play()
localGroup:insert(spriteInstance5)

end
tmr4 = timer.performWithDelay(16000, nexr5,10)
end
tmr8 = timer.performWithDelay(8000,my,1)

local land_01 = display.newImage(“images/land_01.png”)
land_01:setReferencePoint(display.CenterReferencePoint)
land_01.x = _W/2
land_01.y = _H/2 + 130
localGroup:insert(land_01)
[import]uid: 130269 topic_id: 23717 reply_id: 95405[/import]

Take a good look at your code block/execution order and you will see that the player is the last thing put in the display group of your code. If you follow the instructions by Peach and dingo, all will work out the way you wish.

You could stick land_01 = nil at the beginning of your code, then immediately after player is inserted into localGroup, call land_01:toFront() as Peach suggested.

Remember to use your print() statements if ever in doubt of your execution order, they will show you the answer. :slight_smile: [import]uid: 21331 topic_id: 23717 reply_id: 95412[/import]

Thank alot guys. your comments were really helpfull to me and my problem also got solved… [import]uid: 130269 topic_id: 23717 reply_id: 95617[/import]