How can add space-key to jump for Platform behavior in construct 2? - windows-10

I'm using the Platform Behavior in Construct 2 for a Windows 10 game. In addition to the arrow key, I would like to use the Space bar to get the sprite to jump. Can I tell it to call into the Platform behavior somehow or get it to let me map space bar as well as up arrow to 'jump'?

You certainly can. You can use an action called "Simulate Control" to simulate pressing left, right, or up. So as your event, use Keyboard->on Key Pressed (Space Bar). Then for the action Player->Simulate Control (Up Arrow). This will allow you to press space bar to have your character jump. Additionally, you can turn off default controls for the platform behavior and do custom controls for left, right, and up using the same strategy.

The best way to go about doing this is by adding an event that handles the Space Button. Make sure to add the keyboard object in your layout, and in the event sheet, you want to make an event that handles the keyboard -> on key pressed (choose the spacebar when asked) -> choose whatever object you want to jump with the Platform behavior -> Set Vector Y to whatever increment you'd like to jump. Be sure to list this value as negative. The y-axis in C2 is inverted, so negative numbers mean up.
Hope this helps!

Related

How to create a scalable multi-line button in Godot?

A Button in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
Since the Button is in a Container, it is in control of its rect_size. The best we can do is specify a rect_min_size. There is no layout preset to have a Control depend on children Control. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size for the Button depending on the RichTextLabel. We can ask it for the height of its content with get_content_height. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield).
Apparently you don't want the Container to control the height of the Button. If that is the case, I think you can remove all the flags from size_flags_vertical.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container expand the width of the Button as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal.
Then, with the RichTextLabel properly set to take as much width of the parent Button as possible, you can read it height, and use it to set the height of the rect_min_size of the Button.
One more thing: you want to set the mouse filter of the RichTextLabel to Ignore or Pass, or it will prevent pressing the Button.
This is the code I came up with:
var b := Button.new()
b.size_flags_vertical = 0
b.size_flags_horizontal = SIZE_EXPAND_FILL
add_child(b)
var l := RichTextLabel.new()
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
l.set_anchors_and_margins_preset(Control.PRESET_WIDE)
l.text = "Some\nMultiline\nText"
b.add_child(l)
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
I'd like this to happen automatically depending on the amount of text inside
Sadly changing the text does not resize, nor change the minimum size of the RichTextLabel. And RichTextLabel does not have a "text changed" signal. Nor "bbcode text changed" signal. Furthermore, it might not be feasible to intercept these properties (see append_bbcode et.al). It is proabaly easier to do with a regular Label.
Anyway, what I'm going to suggest for this is to make a Control that wraps the RichTextLabel, offers whatever interface you actually need, and in any method where you change the text, afterwards, you do the equivalent of this:
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
(Godot 3.x)
Without using scripting, it is also possible to achieve the same goal by wrapping both nodes as sibilings within a container, for example a MarginContainer. Enable the RichTextLabel's fit_content_height property, which will result in the label expanding the container's area as much as necessary, which will in turn resize the Button.

How to keep mouse keys around

My platform is Linux, and there is a shortcut Alt + Left Shift + Num Lock to enable mouse keys TEMPORARILY. They say this feature is provided by X server, so it can be used on all desktop environments based on X. The problem is that the effect doesn't last long. The keypad will switch back to normal keypad automatically, and cannot be used to emulate a mouse. Therefore, whenever I want to move the cursor, the result may become scrolling to the bottom of the current document, which is annoying. Is there any way to prevent X from switching the keypad back to its original keypad function automatically? Thanks.

Cadence Virtuoso Layout L phantom objects

I have a cell (call it A) which is used once in a hierarchically higher cell (call it P). When I place A in P, its borders are rather larger than the actual content of A. When I descend to A and zoom-fit, it is way zoomed out, indicating there is something present way out on the edges.
I may have dragged objects there at one point but currently there is nothing visible. It is driving me crazy in terms of aligning objects, etc.
Is there any way to clean this up or something?
If I recall Cadence used to have a problem with leaving steiners behind when you moved routes. They are not visible but the db treats them as real objects for the bbox calculation. According to Cadence, deleting the objects should not harm anything. Open the layout in edit mode and paste this code into the CIW. This will delete all the steiner objects in your layout. If this was the root cause after saving you should see the bbox return to normal.
cv=geGetEditCellView()
foreach( item cv~>steiners
dbDeleteObject( item )
)
This thread may be considered "dead," but hopefully this helps.
It is possible the layers that are not visible are turned off.
To turn them on, go to the layers pane on the left. (If it is not there you can turn it on by going to Window —> Assistants —> Layers)
You can then click the drop down arrow in the top right corner and click Edit Valid Layers.
Then, click all valid in the Set Valid Layers popup. Click Ok.
Finally, check the Used Layers Only checkbox in the Layers pane. Look for any layers that weren't there before that you don't need.
Usually it happens when you draw the cell in LayoutXL, particularly when you insert pins.
Layer and purpose in these pins are selected separately for some reason, that is why it is easy to enter "impossible" combination.
Nothing happens, then you do it again and continue drawing. But there are several invisible squares that will continuously frustrate your inner perfectionist. You do the following:
Open this cell's layout, switch to Virtuoso window and enter:
lppList=list()
then:
foreach(shape hiGetCurrentWindow()~>cellView~>shapes if( (member(shape~>lpp lppList)==nil) then lppList=cons(shape~>lpp lppList)))
You have created the list with all layers in this layout, you can view it by entering:
lppList
You'll get something like this:
(("NW" "drawing")
("NP" "drawing")
("weird" "guy")
("M1" "pin")
("M3" "pin")
)
If you find a weird guy in this company, just enter the following command:
foreach(shape hiGetCurrentWindow()~>cellView~>shapes if((shape~>lpp == list("weird" "guy")) shape~>lpp = list("prBoundary" "drawing")))
If you see that some squares, labels (or whatever unseen before) appears as prBoundary, just delete it, save, and your layout will be small and shiny again.

preventing intellisense suggestion boxes from stealing focus for up/down arrows

When I type "std::" in Visual Studio, I get a list of the members of the std namespace in an Intellisense dropdown. That's good; I like that. Then, pressing the down key will start to cycle through the elements in the dropdown.
But usually, when I press the down key with a dropdown active, I don't want to browse through the dropdown; I want to look at the next line of code. Is there a way to make that the default behavior?
I am aware that shift+down will perform the desired function (move to the next line).

When two CCMenuItem overlaps each other, is it possible to prioritise one over the other?

I have 2 CCMenuItems A and B
A is a screen-wide transparent button
and B is an actual button that is set to visible when A is touched
Currently, when I'm touching B, A responds with it's selector method and basically B does not respond because the touch is 'taken' by A's selector.
I need B to be responding even though A is a screen-wide button so- Is it possible to prioritise B's selector when it is pushed?
To summarize, I'm toggling B's visibility via A and would like to be able to use B when it is visible.
Is this possible? How can it be done?
for me worked adding one menu in one layer and another menu in other layer
I)
Yes, You can prioritize your CCMenuItems by setting Z-Order.
First button that gets touch is the button with lowest Z-Order.
II)
And if you want to prioritize your CCMenus, you need to setTouchPriority(..) them.
The less priority you give, the earlier your CCMenu will handle the touch. (CCMenu's default value is -128 ).
Either you can set the buttons yourButton.isEnabled to NO or you can just move the A-button off the scene when you don't want it to take input.
It's possible to use an additional CCMenu with a higher z-order for the button B.

Resources