I'm trying to make a custom behavior and I'm not very familiar with physicsjs.
According to the docs in github I'm supposed to use var bodies = this.getTargets(); to iterate through the bodies
, but I keep getting an undefined is not a function error.
fiddle
What am I doing wrong?
Looks like the physicsjs version was 0.5.2 in the jsFiddle. The method getTargets was only introduced in 0.6. Here's an updated version of the fiddle.
http://jsfiddle.net/r8xum92m/3/
also make sure to use .on() instead of .subscribe() now.
Related
There used to be a method named buildArguments() which was very useful for viewing query arguments. It seems that it was removed after the package version 9.0.0.
I was using it to print my queries to the console, so I was able to spot any mistakes. Was a new method introduced to replace buildArguments()?
I have seen some old questions/answers that said it's impossible to create a type alias on Flutter. I just want to make sure whether it's the case, as the language seems to have been updated numerous times since.
My specific question is, how can I make a type alias like this:
typealias Json = Map<String, dynamic>;
?
Or is there any workaround, because I've tried to use empty mixin to do this but it says that there are 18 missing method implementations.
Small update on Randai Schwartz's comment.
The feature seems (as of April 2021) almost ready and will probably be released in the next minor version or the one after it.
When you read this, it is probably worth checking the following issue:
https://github.com/dart-lang/language/issues/65
This should allow to do:
typedef NewTypeName = OldTypeName;
Update:
Flutter officially supports now typedefs. :)
So you can just use my code example above.
At this point, typedefs are supported only for Function types (https://dart.dev/guides/language/language-tour#typedefs). There is talk of adding more, but not any time soon (https://github.com/dart-lang/language/issues/115).
Flutter 2.2 has been released together with Dart 2.13, now SimonEritsch code should work as you wanted as long as you run flutter upgrade on your terminal or upgrade your dart.
In Swift 3.0, the automated changing of function names due to the "Omit Needless Words" rule has caused two functions in an ObjC class to be the same.
- (void)showLoader;
...and...
- (void)show __deprecated_msg("User 'showLoader'");
The problem is that these functions are within a third party Cocoa Pod (otherwise I would just delete the unnecessary 'show' function).
This results in getting the error "Ambiguous use of 'show'" when I try to invoke the function like this:
loader?.show()
Is there a way to reverse the automatic changing of function name in Swift 3.0 or to help the compiler know which function I want to invoke?
Thanks for your help!
See MartinR's answer to my similar question here: Converting to Swift 3 renamed my own Objective-C method
If you owned the code, you could use NS_SWIFT_NAME(showLoader()) after your method declaration to force the ObjC-to-Swift method conversion to be named what you want:
- (void)showLoader NS_SWIFT_NAME(showLoader());
I think it's worth mentioning even though in your case it doesn't exactly solve your problem because you don't own the code.
You can work around this by calling
loader?.perform(Selector("showLoader"))
You will see a warning from the compiler, but it will compile successfully, and things will work correctly at runtime.
I have just finished converting my game using the Entity and Component base architecture (GameplayKit) that apple introduced in iOS9.
I cannot figure out how to check that a current state (GKStateMachine) does not equal a state.
Say I want to check that the currentState is equal to my GameOverState, I would say this
if self.stateMachine.currentState is GameOverState {...
How would I check if the current state does not equal GameOverState, the "... is ..." sytanx is new to me so I am not sure how to call it.
I ran into this issue myself. It doesn't seem like ther is an inverse to is, so the only option I could see was to wrap the conditional statement to invert the boolean. So you would do like the following...
if !(self.stateMachine.currentState is GameOverState) {...
I found it hard to find documentation... so for yours, and others reference:
Documentation on the is operator (section titled "Type-Casting Operators")
Occasionally, I find myself in situations where it would be useful to do something like this:
HTML::FormHandler::Field::Text->new(
name=>'name',
label=>'Name',
value=>'Ryan'
)->render();
There's nothing in the docs I've found that indicate that this shouldn't work. But apparently it doesn't because I get an error saying that the render routine doesn't exist in HTML::FormHandler::Field::Text.
Maybe I'm misunderstanding how widgets get applied and rendered, but I sure wish this or some alternative worked! Sometimes, it doesn't make sense to build up a whole "form" just for one field. Any thoughts?
It is called chaining. It is only going to work if method returns $self.
An article about this: http://www.perlmonks.org/?node_id=448444
Regards,