我试图从node.js服务器脚本与我的arduino交谈.
这是我的代码:
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
, SerialPort = require('serialport').SerialPort;
//SERIAL
var portName = '/dev/ttyACM0';
var sp = new SerialPort(); // instantiate the serial port.
sp.open(portName, { // portName is instatiated to be COM3, replace as necessary
baudRate: 115200, // this is synced to what was set for the Arduino Code
dataBits: 8, // this is the default for Arduino serial communication
parity: 'none', // this is the default for Arduino serial …Run Code Online (Sandbox Code Playgroud) 我想以编程方式更改我的Bootstrap选择selectpicker的标题。
我尝试了以下不起作用的JS代码。
$('#myPicker')
.selectpicker({title: 'New title'})
.selectpicker('render');
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以做到这一点吗?
html twitter-bootstrap bootstrap-select bootstrap-selectpicker
如何在 create React app 或 craco 中完全关闭捆绑?我正在尝试使用 craco 来完成此操作,我的 webpack 配置如下:
configure: {
/* Any webpack configuration options: https://webpack.js.org/configuration */
mode: 'development',
optimization: {
minimize: false,
},
devtool: 'eval-source-map',
},
Run Code Online (Sandbox Code Playgroud)
我需要关闭捆绑,因为即使使用源映射,Firefox 中的性能分析器(瀑布)仍然显示一些来自bundle.js 的调用,这...根本没有帮助,因为一些调用来自“bundle.js 行” 3051 %3E eval:81828” - 单击时,显示“未找到行”。“性能”选项卡中的“调用树”也只显示bundle.js (eval:####) 调用。当单击这些行时,它会将我带到如下所示的代码:
我正在尝试优化 Phaser webgl 游戏,但捆绑使事情变得非常困难。任何帮助,将不胜感激。
哦,还有一件奇怪的事情 - 当查看 Phaser 调用的 Waterfall 记录时 - 它通常以奇怪的损坏的“bundle.js%20line%20####%20%3E%20eval:######”开始#" 调用,但在其下方有phaser.js 调用,并带有指向调用它的代码行的工作链接。
相关package.json依赖项:
"@craco/craco": "^7.0.0-alpha.3",
"phaser": "^3.55.2",
"react-dom": "^17.0.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^5.0.0",
Run Code Online (Sandbox Code Playgroud) 我想用 Phaser 3 做一个音频输入可视化器,我\xe2\x80\x99m 试图将麦克风输入到着色器,但我\xe2\x80\x99t 找不到一种方法让它工作。
\n我对着色器有基本的了解,我可以使用图像纹理,但我真的不了解如何提供声音。我检查了在 Three.js 中制作的工作示例:Three.js webaudio - 可视化工具,并且我已经设法以 1024 个数字的 Uint8Array 形式从麦克风获取声音输入。
\n这里 \xe2\x80\x99s 着色器 I\xe2\x80\x99m 使用:
\n// simplesound.gsl.js\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nprecision mediump float;\nuniform vec2 resolution;\nuniform sampler2D iChannel0;\n\nvarying vec2 fragCoord;\n\nvoid main() {\n vec2 uv = fragCoord.xy / resolution.xy;\n vec2 mu = texture2D(iChannel0, uv).rg;\n\n float y = uv.y - mu.x;\n y = smoothstep(0., 0.02, abs(y - 0.1));\n\n gl_FragColor = vec4(y);\n}\nRun Code Online (Sandbox Code Playgroud)\n这是我的场景代码,试图使其工作:
\nimport Phaser from \'phaser\';\n// This will provide the array …Run Code Online (Sandbox Code Playgroud) 我需要将文本颜色从红色切换到绿色,反之亦然.
<div id="logoup">DEEP</div>
<button id='btn'>CLICK</button>
Run Code Online (Sandbox Code Playgroud)
CSS
#logoup{
color:red;
}
.greened{
color:green;
}
Run Code Online (Sandbox Code Playgroud)
JS
$("#btn").click(function(){
$('#logoup').toggleClass('greened');
});
Run Code Online (Sandbox Code Playgroud)
不行.控制台是空的.
我在html5中构建了这个进度条.该栏是可点击的,当您点击每个部分时,您会获得解释.它工作但不是在IE8中.谁能告诉我什么是狼?我已经工作了一个月但没有!一点帮助.:-)
我正在尝试访问存储在ViewBag中的列表的元素,如下所示:
function equipamentoTemControle() {
for(i = 0; i < @ViewBag.qtdEquipamentos; i++) {
var contratocod = @ViewBag.DadosEquipamentos[i].contratocod;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,试图访问时contratocod属性索引的我在Visual Studio说,可变我不存在.我如何访问?
我正在按照本教程使用 Phtomstorm 的样板构建多场景游戏模板。我在 GameScene.js 的 preload() 函数中添加的徽标图像收到 404 错误。我觉得我已经按照 T 的说明进行操作,但可能没有正确暴露 webpack 中的资源,因为我是这个工具的新手。
\n我在让这个 logo.png 显示在屏幕上时做错了什么?
\n教程 - https://phasertutorials.com/creating-a-phaser-3-template-part-1/
\n项目模板 - https://github.com/photonstorm/phaser3-project-template.git
\n索引.js
\nimport Phaser from "phaser";\nimport config from \'./Config/config\';\nimport GameScene from \'./Scenes/GameScene\';\n \nclass Game extends Phaser.Game {\n constructor () {\n super(config);\n this.scene.add(\'Game\', GameScene);\n this.scene.start(\'Game\');\n }\n}\n \nwindow.game = new Game();\nRun Code Online (Sandbox Code Playgroud)\n配置文件
\nimport \'phaser\';\n \nexport default {\n type: Phaser.AUTO,\n parent: \'phaser-example\',\n width: 800,\n height: 600\n};\nRun Code Online (Sandbox Code Playgroud)\n游戏场景.js
\nimport \'phaser\';\n \nexport default class GameScene …Run Code Online (Sandbox Code Playgroud) 我有一个包含 JSON 的文本字符串,如下所示:
'{ "d" : [ "test0", "test1", "test2" ] }'
Run Code Online (Sandbox Code Playgroud)
我想以行的形式检索数组的项目。
+------------+
| data |
+------------+
| test0 |
| test1 |
| test2 |
+------------+
Run Code Online (Sandbox Code Playgroud)
网络上的所有示例都展示了如何使用“对象数组”完成它,但我想用一个简单的“字符串数组” MS 示例来完成。
默认查询
+------------+
| data |
+------------+
| test0 |
| test1 |
| test2 |
+------------+
Run Code Online (Sandbox Code Playgroud)
只返回一个表,其中包含每个条目的键、值、类型
+-----+-------+------+
| key | value | type |
+-----+-------+------+
| 0 | test0 | 1 |
| 1 | test1 | 1 |
| 2 | test2 | 1 |
+-----+-------+------+ …Run Code Online (Sandbox Code Playgroud) 正如标题所说。从“游戏”对象启动场景时,有没有办法停止所有正在运行的场景?
目前,当我game.scene.start(...)从场景对象外部调用时,什么也没有发生。我当前的解决方案是保留一个指向最新启动的场景的全局变量(在我的所有场景中,我使用create()类似的方法重置函数中的全局变量currentScene = this;),所以当我想启动一个新场景时,我调用currentScene.scene.start(...). 但显然这不可靠,因为我可能忘记currentScene在所有场景中重置我的全局变量(),等等......
编辑:
为了澄清我想要实现的目标:我正在制作一个带有几个场景和一些游戏对象的小型多人游戏。我有一个“套接字”模块,用于处理客户端和服务器之间的所有流量(我使用的是 socket.io)。我想做一些类似的事情:
this.socket.on('game_end', (data) => {
// Server decides when the game stops and sends an event to all clients.
// Here I need to stop the currently running scene (i.e. SceneInGame)
// and show the "game finished / results" scene.
this.game.scene.start('SceneGameEnd');
// ^ That doesn't work. SceneInGame keeps playing and SceneGameEnd doesn't start
});
Run Code Online (Sandbox Code Playgroud) javascript ×6
html ×2
node.js ×2
webpack ×2
asp.net-mvc ×1
babeljs ×1
c# ×1
canvas ×1
css ×1
debian ×1
html5 ×1
jquery ×1
progress-bar ×1
raspberry-pi ×1
reactjs ×1
serial-port ×1
shader ×1
sql-server ×1
usb ×1
viewbag ×1