Debug object is undefined - phaser-framework

I have looked at a bunch of different examples of peoples code and they are using something like:
this.game.debug
I have probably 20 combinations e.g.
this.game.debug
this.scene.debug,
this.scene.game.debug
etc.. but cannot find this debug, can anyone guide me on where to find this debug object?

Phaser 3 comes with physics debugger, that can be enabled by configuration.
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'phaser-example',
physics: {
default: 'arcade',
arcade: {
debug: true,
gravity: { y: 200 }
}
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
Here a working example, that gives you something like this:

Related

Phaser 3 Arcade physics not getting activated

I am using Phaser 3(3.24) and following is my config to initialize the game
GAME_CONFIG: {
type: Phaser.AUTO,
backgroundColor: '#fff',
scale: {
width: 1200,
height: 470,
mode: Phaser.Scale.ScaleModes.NONE,
},
parent: 'marathon-game',
physics: {
default: 'arcade',
fps: 60,
arcade: {
gravity: { y: 300 },
debug: true,
},
},
}
When I start my first scene and check this.scene.physics it returns undefined...any idea of why this would happen or what could I be doing wrong.
I think it's because your scene object is missing from the config. so if your scene is not a class use:
GAME_CONFIG: {
...the_rest_of_your_config
scene: {
preload: preload,
create: create,
update: update
}
}
Or:
GAME_CONFIG: {
...the_rest_of_your_config
scene: name_of_your_scene_class_goes_here
}

JointJS - How to change colour of remove link icon

In JointJS the remove link SVG that appears is a red circle with a white X in it. I would like to change the colour of the red circle for all remove link icons. Anyone know how to do this?
Thanks!
Tried reading the following but couldn't find what I wanted:
https://resources.jointjs.com/demos/kitchensink
I want to do something like this:
defaultLink: new joint.shapes.app.Link({
attrs: {
remove: {
circle: {
fill: '#634ee9'
}
}
}
}),
I want the red 'remove link' circle to change to a blue/purple one
You can implement your own remove button
this.paper.on({
'link:mouseenter': function (linkView) {
linkView.addTools(new joint.dia.ToolsView({
tools: [
new joint.linkTools.Vertices({ snapRadius: 0 }),
new joint.linkTools.Remove({
distance: 20
}),
new joint.linkTools.Button({
markup: [{
tagName: 'circle',
selector: 'button',
attributes: {
'r': 15,
'stroke': '#fe854f',
'stroke-width': 1,
'fill': 'white',
'cursor': 'pointer'
}
}, {
tagName: 'text',
textContent: 'X',
selector: 'icon',
attributes: {
'fill': '#fe854f',
'font-size': 8,
'text-anchor': 'middle',
'font-weight': 'bold',
'pointer-events': 'none',
'y': '0.3em'
}
}],
distance: -50,
action: function () {
var link = this.model;
link.remove();
}
})
]
}));
}
})

Add tween to scene but do not play it inmediately

I'm adding tweens to scene using scene.add.tween({config}) and the added tween plays automatically. How can I prevent this?
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: { y: 200 }
}
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.setBaseURL('http://labs.phaser.io');
this.load.image('logo', 'assets/sprites/phaser3-logo.png');
}
function create ()
{
var logo = this.add.image(config.width / 2, config.height / 2, 'logo');
var tween_logo = this.add.tween({
targets: logo,
duration: 1000,
scale: 2,
ease: 'Linear',
yoyo: true,
repeat: -1
});
}
<script src="https://cdn.jsdelivr.net/gh/photonstorm/phaser#3.18.1/dist/phaser.min.js"></script>
In your tween config add the paused property and set it to true.
So, your tween config would be:
var tween_logo = this.add.tween({
targets: logo,
duration: 1000,
paused: true,
scale: 2,
ease: 'Linear',
yoyo: true,
repeat: -1
});
Here is a link to the docs for the config to see other properties:

Highcharts export server does not export labels

Demo: https://jsfiddle.net/L6ca89dh/4/
When I export (click the hamburger and click export SVG) the Data-Labels display fine.
When I use my highcharts-export-server they do not:
*** This is how is is supposed to look:
Code snippet of chart item
var chart = {
title: {
text: null
},
time: {
useUTC: false
},
chart: {
width: 1200,
height: 600,
plotBackgroundColor: null,
plotBorderWidth: 0,
plotShadow: false,
spacing: 0,
type: 'spline'
},
xAxis: {
//startOnTick: true
},
yAxis: {
title: {
text: 'Performance (%)'
},
//min: 0
},
legend: {
enabled: true,
navigation: false,
itemStyle: {"fontSize": "11px", "fontWeight": "normal"}
},
rangeSelector: {
enabled: false
},
scrollbar: {
enabled: false
},
navigator: {
enabled: false
},
credits: {
enabled: false
},
plotOptions: {
spline: {
compare: 'percent',
marker: {
enabled: true
}
},
},
series: series
};
Do you mean that series labels are not visible on an exported image when using node export server (https://github.com/highcharts/node-export-server) on your side? If so, the reason behind it is because the series-label script (https://code.highcharts.com/modules/series-label.js) isn't included among other additional scripts (such as xrange) in the build.js file. All you need to do is to add the following:
'{{version}}/modules/series-label.js': 1
inside the cdnScriptsOptional array and run node build.js. For more information you can visit repo of the exporting server (https://github.com/highcharts/node-export-server).

extjs 4 grid in hbox does not appear

I dont know what to do...
Without hbox the grid appears,
but with hbox not.
I added with & height and flex to each child element,
but it doesnt work...
Thanks in advance!
And here's the code:
Ext.onReady(function() {
var myStore = Ext.create('Ext.data.SimpleStore', {
fields: [ 'bMin', ], });
var myData = [ { "bMin": 10, } ];
myStore.loadData(myData);
var grid = new Ext.grid.GridPanel({
layout : { type : 'hbox', align : 'stretch', flex:2,
Height: 150,
Width: 300,
},
cls: 'custom-grid',
store: myStore,
columns: [
{text: "bMin", dataIndex: 'bMin', type: 'float',},
],
viewConfig: {
emptyText: 'No records',
forceFit : true,
},
renderTo: Ext.getBody(),
});
var myPanel = new Ext.Panel({
layout : {
type : 'hbox',
align : 'stretch',
},
title: 'Hello',
minHeight : 150,
minWidth: 300,
Height: 150,
Width: 300,
items: [
grid,
{xtype: 'button', width: 50, height: 50, flex: 1}
],
renderTo: Ext.getBody()
});
});
On the Grid you don't need a 'layout' config, also when using an HBox Height and Width is ignored on the child components so using flex is the way to go. I also added a 'pack' attribute to the hbox layout.
Try this:
Ext.onReady(function() {
var myStore = Ext.create('Ext.data.SimpleStore', {
fields: [ 'bMin', ], });
var myData = [ { "bMin": 10, } ];
myStore.loadData(myData);
var grid = new Ext.grid.GridPanel({
flex: 1,
cls: 'custom-grid',
store: myStore,
columns: [
{text: "bMin", dataIndex: 'bMin', type: 'float',},
],
viewConfig: {
emptyText: 'No records',
forceFit : true,
},
renderTo: Ext.getBody(),
});
var myPanel = new Ext.Panel({
layout : {
type : 'hbox',
align : 'stretch',
pack: 'start'
},
title: 'Hello',
minHeight : 150,
minWidth: 300,
Height: 150,
Width: 300,
items: [
grid,
{xtype: 'button', flex: 1, text: 'test'}
],
renderTo: Ext.getBody()
});
});
JSFiddle Example:
http://jsfiddle.net/vzURb/2/
I see a number of problems here...
height and width config properties should not be capitalized
The flex, height, and width properties should all be on the panel itself, NOT on the panel's layout
The flex attribute will be weighted, so using flex: 1 on your button and flex: 2 on your panel will almost certainly not be what you are looking to do
You have renderTo on the grid, which is supposed to be inside your panel, so it should not use this config
You have commas at the ends of property lists, this can lead to lots of problems
You have type on a column, which is not a valid config
You don't need the layout on the grid
I can't tell exactly what it is that you want to do, but having an hbox layout with a button as the second item will look quite strange. But, if that is what you are intending, this is probably more what you want:
var grid = new Ext.grid.GridPanel({
cls: 'custom-grid',
store: myStore,
columns: [
{text: "bMin", dataIndex: 'bMin'}
],
viewConfig: {
emptyText: 'No records',
forceFit : true
}
});
var myPanel = new Ext.Panel({
layout : {
type : 'hbox',
align : 'stretch'
},
title: 'Hello',
height: 150,
width: 300,
items: [
grid,
{xtype: 'button', width: 50, height: 50, flex: 1}
],
renderTo: Ext.getBody()
});

Resources