Since I have to change state.active from false to true alot through #click, I was wondering if there is a shorter way in doing so than:
state.active = !state.active
I've tried #click="!state.active" which doesn't seem to work.
Related
Thank you for your time
I have a large animation I am working on with several if statements with many outputs
I join the outputs with & ampersand and it all works ok, but when I try to call the visibility of a movie clip, it will not work. Here is a simple one I wrote using three movie clips.
this.black_sw.addEventListener("click", fl_ClickToHide.bind(this));
function fl_ClickToHide()
{ if(this.black_mc. visible== true)(
this.black_mc.visible = false
this.redball.visible = true
)
else if(this.black_mc. visible== false)
(this.black_mc.visible = true
this.redball.visible = false)
}
This does not work console error if I add a "&" to join the statements also console error, deleting
one of the (visible = ) conditions in each part, it works, why, I am stumped.
best regards peter
this.black_sw.addEventListener("click", fl_ClickToHide.bind(this));
function fl_ClickToHide()
{
if (this.black_mc.visible)
{
this.black_mc.visible = false
this.redball.visible = true
}
else
{
this.black_mc.visible = true
this.redball.visible = false
}
}
This should work
So I have been trying to create a pause menu for the past few hours. However, I cannot figure out how to stop the rigidbodies from moving. If there is a way to stop all rigidbodies at once, please tell me, if not, I can set it to each and every script with a rigid body. Here is my code so far:
extends Position3D
onready var charCamera = get_viewport().get_camera()
##var direction = Camera.global_transform.basis.get_euler()
signal spawned(spawn)
export(PackedScene) var spawnling_scene
var linear_velocity_on_pause = 0
var not_paused_anymore = false
var paused = false
#var Popup1 = self.get_parent().get_parent().get_parent().get_node("Popup")
func _physics_process(_delta):
if self.get_parent().get_parent().get_parent().get_node("Popup").visible == false:
if Input.is_action_pressed("leftClick"):
spawn()
if paused == true:
not_paused_anymore = true
paused = false
if self.get_parent().get_parent().get_parent().get_node("Popup").visible == true:
linear_velocity_on_pause = spawnling_scene.instance().linear_velocity
paused = true
spawnling_scene.instance().set_mode(1)
spawnling_scene.instance().linear_velocity = get_parent().get_parent().get_parent().get_node("LinearVelocityOf0").linear_velocity
if not_paused_anymore == true:
spawnling_scene.instance().set_mode(0)
spawnling_scene.instance().linear_velocity = linear_velocity_on_pause
not_paused_anymore = false
func spawn():
var spawnling = spawnling_scene.instance()
spawnling.linear_velocity = charCamera.global_transform.basis.z * -100
#spawnling.global_transform.basis = charCamera.global_transform.basis
add_child(spawnling)
spawnling.set_as_toplevel(true)
emit_signal("spawned", spawnling)
##insert pause system
return spawnling
##var spawnling = spawnling_scene.instance()
##
## add_child(spawnling)
## spawnling.set_as_toplevel(true)
I'm not answering the question of how to set the velocity of all rigid bodies to zero.
If you want to make a pause menu, this is what you should know:
Godot has a puse system, which you can use like this to pause:
get_tree().paused = true
And to resume:
get_tree().paused = false
See Pausing Games.
Which Nodes gets to execute when get_tree().paused is set to true depend on their pause_mode property. By default they will all stop, but if you set their pause_mode to PAUSE_MODE_PROCESS they will continue to work when get_tree().paused is set to true. And that is what you want to do with the Node that make up your pause menu UI.
However, that system will not pause shaders. Their TIME will continue to tick. If you want to "freeze" shaders you can set a 0 to their time scaling like this:
VisualServer.set_shader_time_scale(0)
Set it to 1 for normal speed:
VisualServer.set_shader_time_scale(0)
And you can set other values to have them slow down or speed up.
Speaking of slow down and speed up. If you want to do that for the rest of the game (not just shaders), you can use Engine.time_scale. And if there is some timing that you don't want to be affected, you would have to write it using the time functions in the OS class.
I want to isolate a string but I keep getting a setting with copy error. I read the other threads on settingwithcopy warnings but I don't understand why those solutions don't work here.
I've tried using:
df['Title'][i] = delBy[i]
df.Title[i] = delBy[i]
df[df.Title][i] = delBy[i]
df.loc[df.Title][i] = delBy[i]
df.loc[i]['Title'] = delBy[i]
Actual code:
delBy = df['Title'].str.extract(r'(.+?)(?= [bB]y)', expand = False)
for i in df.index:
if pd.notna(delBy[i]) == True:
df['Title'][i] = delBy[i]
else:
continue
If title has keywords by or By (ex: Animal by John) keep only title (Animal). Leave other titles alone (ex: Meditations)
It looks that you want to delete "by ..." part, where it can be done.
Then start from:
delBy = df.Title.str.extract(r'(.+?)(?= [bB]y)', expand = False).dropna()
(note that I added .dropna()).
Then, instead of your loop, just update this column (in place):
df.Title.update(delBy)
A shorter solution, isn't it?
I'm working with clang-format for my Objective-C project, but I'm having difficulty setting it up properly.
Here's my desired result:
- (NSString *)someMethod
{
return #"My String";
}
Here's the actual result after formatting:
- (NSString *)someMethod {
return #"My String";
}
Here's my .clang-format file:
BasedOnStyle: WebKit
AlignTrailingComments: true
ColumnLimit: 120
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerBindsToType: false
SpacesBeforeTrailingComments: 1
TabWidth: 2
UseTab: Never
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
What setting do I need to change to get the formatter to put a line break before the opening brace of an Objective-C method?
For any fine-tuning of your clang-format you are much better off never to use BasedOnStyle because that for me just creates random and hard to debug results.
Easiest way to do this would be probably to set: BreakBeforeBraces: Custom and then set everything up the way you want it in as it says in the documentation:
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
Read at the source code https://github.com/jspahrsummers/libextobjc/blob/master/extobjc/metamacros.h#L158
// expands to true
metamacro_if_eq(0, 0)(true)(false)
when is expand the macro metamacro_if_eq(0, 0) manually, i get the following
metamacro_if_eq0(0) (true) (false)
continue expanding.
metamacro_if_eq0_0() (true) (false)
go on.
metamacro_consume_ (true) (false)
metamacro_consume is defined as:
#define metamacro_consume_(...) // why nothing here ?
then how can I get the expected value of "true" ?
Your production is incorrect. The operations go like this:
metamacro_if_eq(0, 0)(true)(false)
metamacro_concat(metamacro_if_eq, 0)(0)(true)(false)
metamacro_concat_(metamacro_if_eq, 0)(0)(true)(false)
metamacro_if_eq0(0)(true)(false)
metamacro_concat(metamacro_if_eq0_, 0)(true)(false)
metamacro_concat_(metamacro_if_eq0_, 0)(true)(false)
// You made a mistake at this point.
metamacro_if_eq0_0(true)(false)
true metamacro_consume_(false)
true
After the second round of concatenation, true becomes the argument to metamacro_if_eq0_0(). The argument(s) to that macro is/are left in its place. metamacro_consume_() takes any numer of arguments and resolves to nothing.