How I can remove a body elasticity? (andengine) - andengine

My character's body keeps bouncing.
body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(1, 1, 1));
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, true));
How can I prevent this?

Replace with: PhysicsFactory.createFixtureDef(1, 0, 0), so that elasticity is 0.

Related

Deck.GL, Creating a Polygon layer with a rectangle that has a slope

Question
I've been trying multiple ways to create a rectangle that has a slope, tried using the GeoJsonLayer and PolygonLayer to accomplish this. I can't seem to find a way to create the shape and have it extend all the way to the ground on all sides. I use the Z index on the coordinates to tell it what altitude it should put the vertex at.
To give a clear picture of what I'm trying to do, I basically want to have a rectangle that can be sloped on a side but still have it extend until the ground instead of floating in the air.
const data = [
{
contour: [[-122.4, 37.75, 2000], [-122.4, 37.8, 2000], [-122.5, 37.8], [-122.5, 37.75], [-122.4, 37.75]],
}
];
const overlay = new MapboxOverlay({
layers: [
new PolygonLayer({
id: 'polygon-layer',
data: data,
pickable: true,
stroked: true,
filled: true,
wireframe: true,
extruded: true,
lineWidthMinPixels: 5,
getPolygon: d => d.contour,
getFillColor: [255, 0, 0, 100],
getLineColor: [80, 80, 80],
getLineWidth: 1,
transitions: { getElevation: 600 }
})
]
});

How to make Gtk.Box fill all the available space?

The layout looks like on the image below: two boxes encapsulated in vertical box with a specified width. Single big box is positioned on the right. The big box should fill all the available space, however it is not happening despite Gtk.Align.FILL property set.
Please ignore the "Utilization" box.
cpu_utilization_chart = new Chart (cpu.core_list.size);
cpu_frequency_chart = new Chart (1);
cpu_temperature_chart = new Chart (1);
var smol_charts_container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
smol_charts_container.add (cpu_frequency_chart);
smol_charts_container.add (cpu_temperature_chart);
var big_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
big_box.add (smol_charts_container);
big_box.add (cpu_utilization_chart);
attach (title_grid, 0, 0, 1, 1);
attach (grid_usage_labels(), 0, 1, 1, 1);
attach (big_box, 0, 1, 1, 1);
To fix this I ditched Gtk.Grid and replaced it with a Gtk.Box.
pack_end (cpu_utilization_chart, true, true, 0);
pack_end(smol_charts_container, false, false, 0);
And also did smol_charts_container.hexpand = false;

Chart.js2 Radar, how to configure the label padding/spacing?

I have the following Radar chart using Chart.js v2.
My configuration:
legend: false,
scale: {
pointLabels :{
fontSize: 16,
fontStyle: "bold",
}
}
The problem here is the "Communication" label has 0 padding between the label and the number 100. How can I configure this padding and/or fix this issue?
Spent an hour and still can't find the proper label padding options.
My workaround is padding the labels with newlines and spaces:
['行業競爭情況', ''],
['擁有專利', ''],
' 成本控制',
' 現金流',
['', '回本期'],
['', '營運能力'],
['', '行業潛力'],
'行業網絡 ',
'團隊經驗 ',
['計劃的完整性', ''],
The outcome is acceptable:
Make it auto if you wish:
scale: {
pointLabels: {
callback: function (label, i, labels) {}...
I have the same problem as described in the question and also was unable to find a solution using known chart options.
However, here is another workaround to achieve a behaviour similar to the desired padding (although not exactly):
ticks: {
display: false,
max: 11, // notice how this is +1 more than what you actually want
},
gridLines: {
display: true,
color: [
"#dddddd", "#dddddd", "#dddddd", "#dddddd", "#dddddd",
"#dddddd", "#dddddd", "#dddddd", "#dddddd", "#dddddd",
"transparent" ], // notice how the last (additional) line is set to transparent
},
angleLines: {
display: true,
color: "#dddddd",
},
The idea is to add one additional grid line with a transparent color. While this does not cause any padding between the pointLabels and the angleLines, it does cause there to be one gridLine worth of space between the label and the next gridLine. To me, this at least looks a little better.
Note that this is only feasible if you do not need to display ticks (or if you are ok with your scale showing one additional tick value that you don't actually use).
I use chart.js 2.6.0.
I suffered from the same problem as you.
I use only the radar type chart and amended as follows.
// chart.js v2.6.0
function adjustPointPositionForLabelHeight(angle, textSize, position) {
console.log(position.y);
if (angle === 90 || angle === 270) {
position.y -= (textSize.h / 2);
} else if (angle > 270 || angle < 90) {
position.y -= textSize.h;
position.y -= 7; //add source
}
}
Whenever my PR will be merged, pointLabels.padding option will be added ;)
The PR request mentioned by #ketysek was finally merged as of March 2021.
pointLabels.padding
options: {{
scale: {
pointLabels: {
padding: 10, // Enter number here
},
}};
Usually problem occurs with the first pointLabel when it is single liner you can add the callback in options as follows
pointLabels: {
callback: function (label, index) {
/* Hack to add spacing between first pointLabel item and radar graph */
return index == 0 && label.length == 1? [''].concat(label): label;
}
Making pointLabel multi line text solves the problem.
EDIT:
Current version of chartjs is 2.7.3. Upcoming version will probably solves this problem.
var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
-> var pointLabelPosition = scale.getPointPosition(i, outerDistance + 15);

ExtJS - Attributes changes are being ignored during drag action

We are using ExtJS 4.2.1. The width/height attributes of the img won't change in below example when element is dragged beyond the +/-5px y-coordinate. Changes to attribute 'show' are also ignored. However, element can be destroyed and re-created, but this is not desired.
[panel]
var dndLinkSprite = me.surface.add({
type: 'image',
x: bBox.x,
y: bBox.y,
width: 16,
height: 16,
src: '/link.png'
})
...
dragAction: function(panel, e, diff, dndConfig) {
var spriteLink = panel.dndLinkSprite;
if ( diff[1] > 5 || diff[1] < -5 ) {
spriteLink.setAttributes(height, 16);
spriteLink.setAttributes(width, 16);
} else {
spriteLink.setAttributes(height, 0);
spriteLink.setAttributes(width, 0);
};
}
Thanks for your help!
Solved - wrong syntax:
Instead of:
spriteLink.setAttributes(height, 0);
spriteLink.setAttributes(width, 0);
use:
spriteLink.setAttributes({width: 0, height:0} , true);
spriteLink.getEl().dom.setAttribute(height, 16);

Use Firebug command line to force click

I'm trying to use Firebug's command line to force a click event. This is as far as I've got and it's not very far.
document.getElementsByClassName('this_button').click();
Is is it possible to do what I want?
Thank you!
I wonder why no one provided a solution so far.
What you are searching for is this:
function simulateClick(element) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
element.dispatchEvent(evt);
}
For more info see document.createEvent.
I didn't try it in other browsers, but at least it work for me in Firefox 18.0.1.