Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Modify the movement around the anchor
Started by glebiya.studio Jan 25 2019 02:53 PM

4 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

glebiya.studio

[GLOBAL: userInfoPane.html]
glebiya.studio
  • Observer

  • 2 posts
  • Corona SDK

How to make the physical model repeat the movement for the sprite?

 

Link to the video where the problem is clearly shown:

https://youtu.be/vUUNrwYA0TI

 

P.S. The code is in standard patterns called - AnchorPoints



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 939 posts
  • Corona SDK

Physics objects don't really play nice with display groups.

You are experiencing that issue because you are adjusting the display object's anchor point after it has been created. The physics body doesn't respond to changes in the anchor point after it has been created.

All you need to do is destroy the physics body before you change the anchor and then recreate it. Add the following lines of code to lines 50 and 60 and it'll work:

physics.removeBody( logo )  -- line 50
physics.addBody( logo )  -- line 60



[TOPIC: post.html]
#3

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,069 posts
  • Corona SDK

You can turn the body off by setting isBodyActive = false and then back to true later. This is not quite the same so your mileage may vary and both solutions deserve at least some trial and error.



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 939 posts
  • Corona SDK

I don' think that isBodyActive works here as it doesn't affect the anchor of the physics body at all. The only way to reasonably "adjust" the anchor of a physics body is to delete the current body and create a new one.



[TOPIC: post.html]
#5

glebiya.studio

[GLOBAL: userInfoPane.html]
glebiya.studio
  • Observer

  • 2 posts
  • Corona SDK

Thank you all for your help !!! You helped me a lot.




[topic_controls]
[/topic_controls]