How to turn on showPhysics in a Swift UI SpriteView? - swiftui

I have been playing with the SpriteView in iOS14 and its working quite well however, I noticed that some collisions that worked fine when using a UIViewcontroller would be missed using the SpriteView. So I thought to turn on showsPhysics to help with the debug. However I am stumped as to how I can do that as the skView is not available?
Can anyone help, I must be missing something.
cheers
S

So now I feel a bit dumb. The answer was to put the view.showsPhysics = true into the didMove(to view: SKView) call!

it is simple, you just need to add a new parameter wend you initialize the SpriteView:
SpriteView(scene: SKScene(), debugOptions: .showsPhysics)

Related

ROS C++: nh.subscribe vs message_filters::Subscriber<> , nh.subscribe works well but message_filters::Subscriber<> does not work

I'm tring to learn ROS topic, but I met a problem that really confused me.
Here is the origin code. It works well, I can receive the image and pass it to CamImgcb.
mSubCam = mNh.subscribe<sensor_msgs::Image>(TopicNameCamSub,10,boost::bind(&ClientHandler::CamImgCb,this,_1));
But when I change it to this code below, CamImgcb can not receive anything, the whole program is stuck to wait for the image to come.
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(mNh, TopicNameCamSub, 10);
rgb_sub.registerCallback(boost::bind(&ClientHandler::CamImgCb,this,_1));
My question is that aren't those two codes means the exact same thing? Why is there a difference between them? I just can't figure it out.
Does anyone know what is the problem? Please help me and thank you so much!
I had a similar issue a while back and found the solution here.
Try changing:
rgb_sub.registerCallback(boost::bind(&ClientHandler::CamImgCb,this,_1));
To:
rgb_sub.registerCallback(&ClientHandler::CamImgCb, this);
Solved it , the solution is here!
https://answers.ros.org/question/406915/nhsubscribe-works-but-message_filterssubscriber-not/

Casting UIWindow.rootView to UIHostingController<View> which has environment variables

Casting UIWindow.rootView to a hosting controller like:
window?.rootViewController as? UIHostingController<MainTabView>
works fine, unless it has environmentObjects.
As my MainTabView has been initialized with .environmentObject, I cannot cast it to UIHostingController<MainTabView>.
When I try to print rootView's type, Xcode tells:
<_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentGS1_V10Panparella11MainTabViewGVS_30_EnvironmentKeyWritingModifierGSqCS2_11GroupsStore___GS4_GSqCS2_18GroupsPresentation____: 0x7fd8afe5da40>
which I suppose is:
UIHostingController<ModifiedContent<MainTabView, _EnvironmentKeyWritingModifier<GroupsStore, GroupsPresentation>>>
but I'm not able to reach _EnvironmentKeyWritingModifier.
Anybody has an idea?
If there is only one EnvironmentObject the following typecast compiles and works fine.
UIHostingController<ModifiedContent<MainTabView, _EnvironmentKeyWritingModifier<Optional<GroupStore>>>>
Even though this is not a complete answer to the question (since there are multiple EnvironmentObjects) I am posting it here in case it might help someone that uses a single EnvironmentObject.

Using Motion in CosmicMind's Material

When i try to use CosmicMind's motion animation framework, I receive an error whenever I try an example. For example, taken straight from the Sample's repo:
dateLabel.animate(.delay(1),
.duration(0.5),
.background(color: Color.cyan.base),
.completion({ [weak self] in
self?.dateLabel.animate(.delay(1),
.duration(0.5),
.background(color: Color.deepPurple.base))
}))
throws the error 'Extra argument in call'
I can't animate anything because I always receive this error. What can i do to fix it?
Thanks!
I had tested the animation with Material 2.8.1 and all worked correctly. Please make sure you are using the latest Material version. All the best!

locationManeger.requestWhenInUseAuthorization()

Hi all I am on a tutorial for maps but it is using Xcode 7 in the tutorial.
In the tutorial he uses this link but it has been stopped in the new version.
Can anybody let me know the best way to duplicate this?
I have added NSLocationWhenInUseUsageDescription in the plist.
func locationAuthStatus() {
if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
map.showsUserLocation = true
}else {
//cant get this to work in ios10
locationManager.requestWhenInUseAuthorization()
}
}
Any help will be appreciated.
solved....
I realised that I had created a constant named locationManager but spelt it lacationManager instead, I couldn't work out why it was asking me to change it to LacationManager then I realised the spelling mistake.
all works fine now.

How to omit confirmButton &cancelButton from SystemDialog in c++ for Q10?

I am facing a strange problem regarding SystemDialog. I need to omit confirmButton & cancelButton from my dialog. And I put the following code to do so-
SystemUiButton *cancelButton = alertDialog->cancelButton();
cancelButton->setLabel(QString::null);
SystemUiButton *confirmButton = alertDialog->confirmButton();
confirmButton->setLabel(QString::null);
It's perfectly working in Z10. But in Q10 it's not working. My both device running on 10.1
Can you guys please put some feedback regarding this issue?
Thanks.