'Fixed' objects are moving when they shouldn't

Hi,

I am using the ‘Ghosts vs Monsters’ as sample code to try and help me build something, I have been through the level1.lua file and from it built my own level.lua file.

The problem I have is my hudgroup is set to an xAxis of 0, then i’m doing the normal transition on gamegroup, however when the screen moves, the hudgroup also seems to move, whereas in the sample code, the hud sticks in the same place and doesn’t move.

At no point have I used gamegroup:insert(hudgroup) as that is the code I would expect to have the behaviour I am getting. I have also created a brand new object using:

local rectangle = display.newRect(0,0,100,100)

And as expected, that also moves on the transition whereas again on the sample code it doesn’t!

I have changed far too much to start again. Is there anything else that could cause this behaviour?

The transition is definitely on gamegroup, so I would of thought it wouldn’t affect anything that is not in gamegroup.

Any help would be appreciated! thanks

Kevin [import]uid: 72726 topic_id: 14594 reply_id: 314594[/import]

Following on from this as i’ve got no where…

I have now copied and pasted the code from level1.lua on Ghosts and monsters and copied and pasted all the images in to my folder, however the HUD still doesn’t stick on the screen like it does on Ghosts and Monsters… how is this even possible???

[import]uid: 72726 topic_id: 14594 reply_id: 54369[/import]

Don’t insert the hudGroup into gameGroup.

As it will then be part of gameGroup and thus move with it also.

For static groups just do the following :

[code]

local gameGroup = display.newGroup() --Group that can move
local staticGroup = display.newGroup() --Group that doesn’t move

local myHud = display.newImage(“hud.png”)
staticGroup:insert(myHud) --Hud is inserted into staticGroup which doesn’t move
[/code] [import]uid: 84637 topic_id: 14594 reply_id: 54389[/import]

This sounds very odd - is the HUD being set up in level1 or is it being called from another file?

Peach [import]uid: 52491 topic_id: 14594 reply_id: 54390[/import]

im not inserting the hud into the game group, thats what I dont get… I actually copy and pasted the level1.lua file from the Ghosts and Monsters directory along with ALL the images and sounds, and my hud still doesn’t stay. [import]uid: 72726 topic_id: 14594 reply_id: 54397[/import]

@Peach: my level.lua file at this minute is absolutely identical to level1.lua from ghosts and monsters, thats the thing I dont understand.

Even if I just insert a rectangle with:

display.newRect(0,0,100,100)

even that doesn’t stick when the gameGroup moves. [import]uid: 72726 topic_id: 14594 reply_id: 54398[/import]

OK, I just did a test and this is working for me.

In Ghosts VS Monsters, level1, go to line 876 (right above where the pauseBtn is created) and put in this test code;

[lua]testItem = display.newRect( 100, 10, 100, 100 )
testItem:toFront()[/lua]

For me, that moves with the hud group.

Is this what you’re trying to do? [import]uid: 52491 topic_id: 14594 reply_id: 54401[/import]

Sorry that could have been clearer - it doesn’t move, just like the hud group doesn’t move.

Test the code and tell me if that is what you are trying to achieve. [import]uid: 52491 topic_id: 14594 reply_id: 54403[/import]

Hi Peach,

In Ghosts and Monsters… its perfect, in mine… it moves with the screen (as to speak) [import]uid: 72726 topic_id: 14594 reply_id: 54404[/import]

How long is your code? It seems you’ve changed something and don’t recall what - have you been commenting?

If you pauseBtn still exists and behaves as you want it to, look for all references to that and ensure you are treating any new desired hud objects in the exact same way. [import]uid: 52491 topic_id: 14594 reply_id: 54405[/import]

i’ve actually copied and pasted the ghosts and monsters code, copied all images and sounds, and still get the problem.

It has me completely baffled! [import]uid: 72726 topic_id: 14594 reply_id: 54407[/import]

@Peach, even when I look at the changes I made in the file I had before reverting… all I had done really is remove references to things I didn’t need like ‘Poof’, remove sounds that I didn’t have and change the images… None of the actual functional code is broken.

The hud menu appears perfectly… as long as you are at the very left of the screen, if however you are at the right of the screen, the hud popup looks like it doesn’t appear because it is appearing off to the left of what you are looking at. If the hud doesn’t move, this problem wouldn’t occur. [import]uid: 72726 topic_id: 14594 reply_id: 54408[/import]

But you don’t get it when running the sample code from the original folder, correct? If so, there’s code you’re missing :frowning: [import]uid: 52491 topic_id: 14594 reply_id: 54409[/import]

That is correct…

When I look at the code I have now the only group i transition is the gameGroup… so surely anything not in that group shouldn’t move anyways?

I have done a copy and paste from level1.lua, initially I was leaving the images I had in, and it was coming up with errors with the images (as I had them in a folder at the time), however with the errors the hudGroup was working correctly.

When I correctly referenced all of the images so that the error went away… so did the correct positioning of the hud group. [import]uid: 72726 topic_id: 14594 reply_id: 54410[/import]

It’s just one of those times where you need to check and double check all code, there is at least one mistake stopping it from working correctly, as you know.

I know it’s not a fun part of making apps but really, there’s no way to solve this beyond either combing through the code to find and fix your error or starting over and checking it carefully as you go, remembering to comment all changes. [import]uid: 52491 topic_id: 14594 reply_id: 54412[/import]

Out of curiosity I decided to remove the director class so that level1.lua became main.lua and I removed the module line as well as the function new() and the return.

Ran this, and it runs perfectly, the hud stays exactly where it should, no problems at all.

What could director be doing that is causing the hud to fail? [import]uid: 72726 topic_id: 14594 reply_id: 54442[/import]

just implemented director 1.4 today and I also have a problem with this. I think director is inserting all my groups into my localGroup is there anything I can do to get around this? or should I switchback to 1.3 to implement my hud. [import]uid: 39088 topic_id: 14594 reply_id: 56676[/import]

These are questions you need to be asking in the Director Class sub forum, here; http://developer.anscamobile.com/forums/director-class

Peach :slight_smile: [import]uid: 52491 topic_id: 14594 reply_id: 56873[/import]