How can I set the viewport orientation in cocos2d-js 3.0?
I found the variables
cc.UIInterfaceOrientationPortrait
cc.UIInterfaceOrientationLandscapeLeft
cc.UIInterfaceOrientationLandscapeRight
cc.UIInterfaceOrientationPortraitUpsideDown
in CCInputManager.js but no function to actually set them.
And I found this description:
http://www.cocos2d-x.org/wiki/Device_Orientation
but it is different for Android and iOS and that contradicts the cocos run command.
In Android just edit the file
frameworks/runtime-src/proj.android/AndroidManifest.xml
in the project directory. Change
android:screenOrientation="landscape"
to
android:screenOrientation="portrait"
you can change in your project config.json
{
"init_cfg":{
"isLandscape": false,
"isPotrait":true,
"isWindowTop": false,
"name": "untitled",
"width": 960,
"height": 640,
"entry": "main.js",
"consolePort": 6050,
"uploadPort": 6060,
"debugPort": 5086
},
Related
I am creating a watch.json file on glitch.com, following these instructions: https://glitch.happyfox.com/kb/article/60-can-i-change-which-files-cause-my-app-to-restart/
My goal is to NOT automatically restart the browser page after every edit in JS or CSS files. Or when it does, it should throttle to reload only after 50 seconds.
{
"install": {
"include": [
"^package\\.json$",
"^\\.env$"
]
},
"restart": {
"exclude": [
"^public/",
"^dist/",
"\\.js$",
"\\.md$",
"\\.html$",
"\\.css$"
],
"include": [
"\\watch.json"
]
},
"throttle": 50000
}
Sadly, this doesn't seem to work. Any change in JS or CSS files will immediately cause a reload. What could be wrong?
The glitch project is here: https://glitch.com/edit/#!/ml5test-two
The watch.json file refers to build/restart times for full-stack apps, not browser window refreshes. You can turn off "refresh app on changes" in the project menu in the editor. See: https://help.glitch.com/kb/article/46-can-i-turn-off-or-on-automatic-refreshing-of-the-app-preview-when-i-make-changes/
I'm new in Angular. I saw sourcemap in tsconfig.json and by default it is "sourceMap": true. I had few doubts and found this link useful. Still I have the following doubt regarding the same.
I set "sourceMap": false, but couldn't find any change in the app. What will be the actual change if I set so?
Nothing will change in how the app runs.
The change will be in your debugging experience.
Source maps are helpful for debugging code. You write your code in TypeScript, and the compiler turns that source code into JavaScript. When your app is running in a browser like Firefox, the browser is running the JavaScript. Even though the browser is running that JavaScript, if you open the debugger in Firefox, the debugger will display the TypeScript source code and will let you set break points in it. The debugger is able to do that because of source maps, which map the TypeScript source code to the JavaScript runtime code. That is what source maps do: they map the source code to the runtime code to enable source code debugging at runtime.
sourceMap is just for development experience (debug) and normally you don't need these files in production build and if you check angular.json you will found that it 's set to false for you
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false, <----
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
When the sourceMap set to false. the output will be built with out a sourcemap file. And you can't debug with the browser on ts file without that.
sourcemap property enhances your debugging experience, even though the browser can't be able to understand typescript it manages to map your typescript code to javascript code. if in case we need to disable it we need to modify in angular.json file
{
"sourceMap": false, -- modify this attribute
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
I am currently managing a staging environment with some authentication.
I was able to run my tests by embedding credentials to URL like this:
https://johndoe:foobar#app.s.product.com/#login
However, my tests fail because of chrome, dropping this feature(https://www.chromestatus.com/feature/5669008342777856). Is there any other way I can access our staging site? I tried inspecting the popup for credentials and maybe I can sendKeys(), but to no avail.
Thanks in advance!
Have this problem too. My solution is creation chrome extension and add it to chrome on startup.
Create two files in some new folder:
background.js (change user and path with yourth)
chrome.webRequest.onAuthRequired.addListener(
function(details, callbackFn) {
console.log("onAuthRequired!", details, callbackFn);
callbackFn({
authCredentials: {username: "user", password: "pass"}
});
},
{urls: ["<all_urls>"]},
['asyncBlocking']
);
manifest.json
{
"manifest_version": 2,
"name": "Authentication for tests",
"version": "1.0.0",
"permissions": ["<all_urls>", "webRequest", "webRequestBlocking"],
"background": {
"scripts": ["background.js"]
}
}
Pack them into crx (chrome://extensions/ -> Pack extension)
Add this file to project
Add to conf.js:
As first line
var fs = require('fs');
const ext64 = fs.readFileSync('./ext.crx', 'base64');
exports.config = {
...
and to chrome options
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox'],
extensions: [ext64]
}
},
Using the web client of Google Drive, I added a file image called "image.jpg." This was done by dragging the image from the file system (Mac OS.x 10.9.5) to Chrome where I have my drive folder ready to receive the file.
"image.jpg" has EXIF data such "Date Time Digitized" and "Date Time Original, as confirmed by using Preview on the Mac, and the Inspector tool. For sake of discussion, this date is: "Dec 6, 2014, 3:52:45 PM".
Upon making a call to the API such as:
https://www.googleapis.com/drive/v2/files/{fileId}
where fileId is the id of the file "image.jpg" in Drive, the resulting imageMediaMetadata does not contain date properties. Below is the imageMediaMetadata.
"imageMediaMetadata": {
"exposureTime": 0.053308000000000001,
"flashUsed": true,
"cameraMake": "Nokia",
"isoSpeed": 100,
"exposureMode": "Auto",
"colorSpace": "sRGB",
"height": 918,
"width": 1632,
"meteringMode": "Average",
"location": {
"latitude": 47.676632499999997,
"altitude": 0.0,
"longitude": -122.12224833333333
},
"aperture": 2.0,
"exposureBias": 0.0,
"rotation": 0,
"whiteBalance": "Auto",
"cameraModel": "Lumia 920"
}
"date" (imageMediaMetadata.date) is not there.
Why is "date" not in the imageMediaMetadata? How to resolve?
If possible, check your image file to see if it includes the Exif field: Exif/Image/DateTime. If it does not and you are able to add it, that would be a worthwhile test to see if it then produces a date in the metadata.
I am trying to access 'Chrome dev-tool mobile emulator' from custom extension .
I am aware that I cant open dev-tool from custom extension.
Is there any way to trigger mobile emulator from the custom extension? If yes guidance/tutorials will do great help.
What I need - I select a mobile device from my extension and browser will change viewport, user-agent, sensor to emulate selected device. In short I need replica of dev-tool mobile emulator.
Any help/link/code/extension link will do great favour.
You'll have to use setDeviceMetricsOverride via the devtools protocol. You access it at the chrome.debugger chrome extension API. You'll use that method and probably others to set the UA and such.
Example code from my chrome extension.
Example (from #onsy):
chrome.debugger.sendCommand(debuggeeId, "Network.enable", {}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Network.setUserAgentOverride", {
userAgent: deviceData.userAgent}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Page.enable", {}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Page.setDeviceMetricsOverride", {
width: deviceData.width / deviceData.deviceScaleFactor,
height: deviceData.height / deviceData.deviceScaleFactor,
deviceScaleFactor: deviceData.deviceScaleFactor,
emulateViewport: true,
fitWindow: true,
textAutosizing: true,
fontScaleFactor: 1
}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Network.enable", {}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Network.setUserAgentOverride", {
userAgent: deviceData.userAgent}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Page.enable", {}, onResponse);
chrome.debugger.sendCommand(debuggeeId, "Page.setDeviceMetricsOverride", {
width: deviceData.width / deviceData.deviceScaleFactor,
height: deviceData.height / deviceData.deviceScaleFactor,
deviceScaleFactor: deviceData.deviceScaleFactor,
emulateViewport: true,
fitWindow: true,
textAutosizing: true,
fontScaleFactor: 1
}, onResponse);