Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Object misalignment when using "transition.to"
Started by joshuacalebbryan Aug 17 2019 05:55 PM

- - - - -
1 reply to this topic
transition display groups

Best Answer joshuacalebbryan , 17 August 2019 - 06:21 PM

Issue resolved. Just after I posted this, I tried changing the FPS to 60, and that corrected the issue.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

joshuacalebbryan

[GLOBAL: userInfoPane.html]
joshuacalebbryan
  • Enthusiast

  • 32 posts
  • Corona SDK

Hello all,

 

Issue:

 

I am having an issue while moving a display group object using "transition.to".

 

I have several tiles within a display group, which I call "map_tile_group".

 

In the first image, you will see a blue circle in the center of the screen. This is my player/camera center point. It stays in the center of the screen at all times ( it appears off-center because of how I took the screen shots ). The green, tan and blue tiles are just random tiles to help me track movement smoothness.

 

In the second image, you will see that the player has moved down and to the right ( really the map_tile_group has moved up and to the left ). You will also see my issue. When the map_tile_group is moved, each of the tiles appear to have some sort of spacing between them. To me, it seems that each of the child objects ( tiles ) are not being moved in a way that places them next to one another properly.

 

Code Snippets:

 

Movement:

function Camera_Controller.move_camera()
    ...
    ...
    speed = 100 --camera speed
    transition.to( map_tile_group , { x=map_tile_group.x-x, y=map_tile_group.y-y, time=speed  } )
    ...
    ...
end

the x and y variables here are just my way of determining the direction map_tile_group should move based on the keys I press. Further explanation of them should not be necessary for this inquiry.

 

 

 

Triggering Movement:

 

Basically, I have tried two methods of triggering the movement of map_tile_group:

1. A Runtime listener using "enterFrame"

2. A repeating function that runs at a variable time interval

Code from each method is shown below:

 

1.

Runtime:addEventListener( "enterFrame", Camera_Controller.move_camera )

2.

Camera_Controller_Reapeater_Timer = 100

function Camera_Controller_Loop()

    Camera_Controller.move_camera()
    Camera_Controller_Reapeater()

end

function Camera_Controller_Reapeater()

    timer.performWithDelay( Camera_Controller_Reapeater_Timer, Camera_Controller_Loop )

end

timer.performWithDelay( Camera_Controller_Reapeater_Timer, Camera_Controller_Reapeater )

Attempted Solutions:

 

I have changed the speed of the Camera_Controller_Reapeater_Timer to match the "speed" variable found in Camera_Controller.move_camera() along with changing it to a slightly higher number to allow for processing time.

 

A solution I have found it to not use the transition.to method at all, but instead move the map_tile_group x and y value directly as so: 

map_tile_group.x = map_tile_group.x-x
map_tile_group.y = map_tile_group.y-y

Doing this removes the tile spacing problem as described in Issue, but doing so produces a slight but noticeable amount of jitter/lag. I have moved the map_tile_group by increments of 1 pixel up to 50 in testing with the same jitter/lag being present.

 

My PC is quite high in it's specs, so CPU/graphics card concerns should be null.

 

 

I look forward to hearing people's thoughts.

 

Attached Thumbnails

  • first_image.png
  • second_image.png


[TOPIC: post.html]
#2

joshuacalebbryan

[GLOBAL: userInfoPane.html]
joshuacalebbryan
  • Enthusiast

  • 32 posts
  • Corona SDK

  Best Answer

Issue resolved. Just after I posted this, I tried changing the FPS to 60, and that corrected the issue.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: transition, display groups