I have refactored my code in order to use states and classes. The code is cleaner but the callback associated to the onBeginContact is not called anymore. Without classes, it was working as expected.
In Boot.js:
this.game.physics.startSystem(Phaser.Physics.P2JS);
In Game.js:
this.ship = this.game.add.sprite(200, 200, 'ship');
this.ship.animations.add('propulse', [1, 2, 3]);
this.game.physics.p2.enable(this.ship, false);
this.ship.body.addPolygon({}, 30, 35 , 0, 35 , 14, 5);
this.ship.body.onBeginContact.add(this.hitWall, this);
hitWall is not called. I have tried using a simple function but same issue. If you need more information, please ask.
The line:
this.game.physics.startSystem(Phaser.Physics.P2JS);
Should be in Game.js too.
Related
I started working with ND4j recently and came upon an issue I don't have an explanation for.
INDArray test =
Nd4j.create(new double[] {1.0, 1.0, 2.0, 1.0}, new long[] {2, 2}, DataType.UINT16);
BooleanIndexing.replaceWhere(test, 0.0, Conditions.greaterThan(0)); // test not updated
INDArray testCasted = test.castTo(DataType.FLOAT);
BooleanIndexing.replaceWhere(testCasted, 0.0, Conditions.greaterThan(0)); // testCasted is updated
In the code above, an array created with UINT16 datatype doesn't get updated by the replaceWhere function. But when the array is casted to a FLOAT, replaceWhere works as expected. Why is this?
For now just use cast. Please feel free to file an issue and we'll take a look at that at: https://github.com/eclipse/deeplearning4j/issues - it's likely just us forgetting to auto update some of the types. Thanks!
being new to Flot i am struggling a bit. My goal is the present a bar with different data elements in it that must have a different color per element. I want to provide the color per data element.
Any hints on how this can be done?
Example:
[0,100][0,200][0,100][0,200]
All elements with value 100 should be blue and all elements with 200 should be green.
A nice one would be,
[0,100,blue][0,200,green][0,100,blue][0,200,green]
But this off course does not work, it is just an explanation what i want to achieve!
Doing this with multiple data series seems does not work in my case.
Any hints on how this can be done?
You can do it with multiple series, as this is how I have done something like this :)
So in your plot method you would have something like this:
$.plot($('#placeholder'), []); // The array would hold your data
You can also further extend this to provide some options to flot to tell it what to make your chart look like. To do that you pass an object of options after the array.
However, im not quite sure what you need in terms of the Graph, your example gave some numbers but the x coordinate was all 0, im not sure if you just want a bar graph?
Anyway, heres the code of how you would get it to display a bar graph, with one green line and one blue line:
var flotOptions = {
series: {
lines: { show: true, fill: false, lineWidth: 15 }
}
},
var data = [{
color: '#001EFF',
data: [[0, 0], [0, 100]]
}, {
color: '#00FF0E',
data: [[5, 0], [5, 200]]
}];
$.plot($('#placeholder'), data, flotOptions);
I would recommend making it so that the data is automatically generated on a server side, then you can check in javascript, and add the color depending on the y value in the data array of each series.
I have also created a jsFiddle of this for you, so you can go take a look and play around with it. As I have said im not quite sure what you want but this is a good start for you. Good luck!!
I have done some modification and now need to build my own pagination.
So i know prestashop have his own so how can i use them?
I was trying to use in classes/controller/FrontController.php
Use function:
public function pagination($nbProducts = 10)
{....
But can't understand well where and how is formed a pagination itself... i think my php knowledgment is low so i need some help if somebody get understand how is pagination of Prestashop works.
Front Controller assign products and the number of products in smarty variables for the page you want to see.
Here the example with BestSales Page in BestSalesController :
$nbProducts = (int)ProductSale::getNbSales();
$bestSales = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
....
// then assign it to smarty
$this->context->smarty->assign(array(
'nbProducts' => $nbProducts,
'products' => $bestSales
));
There is nothing special or custom things you can do in Front Controller.
If you want to make a custom pagination, take a look at the blocklayered module.
For example, in modules/blocklayered/blocklayered.php at ajaxCall() function, you can specify custom choices for 'the number of products by page' by editing this line :
$nArray = (int)Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int)Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);
This line display 10, 20, 50 and default number of products per page specified in Back-Office/Preferences/Products but you can change it as your wish, example :
$nArray = array(10, 20, 30, 40, 50, 60);
If you want to make customizations, you have to made them in this module, but it wouldn't be simple (the file is hitting 4200 lines, so good luck !).
I'm new to using Dart, and I've been trying to port over some javascript code that I had which worked with svg, creating a path with some segments in it, but I'm struggling to understand how the API for it works.
The following code won't run, but it perhaps illustrates what I'd like to do:
Element i = query("#divsvg");
svg.SvgSvgElement s = new svg.SvgSvgElement();
i.append(s);
svg.PathElement p = new svg.PathElement();
p.pathSegList.add(
p.createSvgPathSegArcAbs(200, 200, 50, 50, 180, false, false)
);
s.children.add(p);
However, as far as I understand from the documentation:
createSvgPathSegArcAbs creates an un-parented path segment
pathSegList is final, so you can't add to it after construction
The PathElement constructor doesn't seem to take any arguments
Am I missing something about how Dart works, or something in the documentation for the svg library? I've spent a few hours looking at the docs, googling, and looking at the tests, but I haven't found anything that seems to cover this (the tests seem to create things using HTML code, rather than the API).
Anything that points me in the right direction will be very much appreciated!
Update
I've spent more time looking at the functions, and the 'finality' of the pathSegList shouldn't prevent it from being changed (it's not const), just replaced.
However, various functions like "add" are explicitly implemented with exceptions if you try and call them, while a few functions (like append) are implemented natively.
According to the debugger:
p.pathSegList.append(
p.createSvgPathSegArcAbs(200, 200, 50, 50, 180, false, false)
);
Will append a path segement, but this will not be present in the 'innerHTML' attribute nor in the final page HTML...
I'm starting to think that the svg support is simply not a "finished", and am getting a bit tempted to just port to canvas, and/or WebGL.
I was able to create a path element and add path segments to it using the appendItem method of PathSegList:
var div = query('#container');
var svgElement = new svg.SvgSvgElement();
div.append(svgElement);
path = new svg.PathElement();
svgElement.append(path);
segList = path.pathSegList;
segList.appendItem(path.createSvgPathSegMovetoAbs(50, 50));
segList.appendItem(path.createSvgPathSegArcAbs(200, 200, 50, 50, 180, false, false));
segList.appendItem(path.createSvgPathSegClosePath());
My application keeps failing to compile when I try to create a Vertex Layout in direct3D 10. Heres the code:
// Create the vertex input layout.
D3D10_INPUT_ELEMENT_DESC vertexDesc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0}
};
// Create the input layout
D3D10_PASS_DESC PassDesc;
mTech->GetPassByIndex(0)->GetDesc(&PassDesc);
HR(md3dDevice->CreateInputLayout(vertexDesc, 2, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &mVertexLayout));
It fails in CreateInputLayout(), I was also under the impression that HR() is meant to catch problems such as these and make suggestions in these cases, however it doesn't appear to do that. Although as with many cases I may be completely wrong on that. The prompt that comes up is :
Unhandled exception at 0x757fd36f in CourseworkApp.exe: 0x0000087A: 0x87a.
I think this is mainly related to errors with pointers but I am unsure. Any help would be much appreciated.
You should make your color format "DXGI_FORMAT_R8G8B8A8_UNORM" and change "HR(md3dDevice->CreateInputLayout..." to "if(FAILED(md3dDevice->CreateInputLayout...)) {//Handle errors}".
I think that might help fix the problem.