cocos2d-js, is there a way to stop cc.game and rebind it to another canvas and then restart the game? - cocos2d-js

I try to have a canvas inside a query mobile page, first time it runs well, but when I switch to another page and removed the page containing canvas from the dom, and switch back again, I try to setup the game once more, it didn't work
how to end the cc.game properly so I can reconfigure it again?

Related

Why doesn't rails turbo-stream-from update the dom outside the tab?

Why doesn't rails turbo-stream-from update the dom when we're not in the application tab in the browser?
When we go back to the tab in the browser where the application is, all items are inserted at once at this point.
I don't know the logic exactly
but I think there are 2 possibilities:
it uses Browser Window focus event, so the update will be done when the user has opened the tab
it's a limitation from the browser, to prevent unnecessary CPU usage, it doesn't want to update the content if user is focusing on another tab

How to navigate back to a Page and avoid reloading webview?

I have a Windows Phone Store app (XAML) with a Page (MainPage.xaml) that has a webview that loads content and URLs. At certain point i have to navigate to a different windows phone page (Page2.xaml), once the data there is submitted i navigate back to MainPage.xaml, but the webview control always reloads the content and user has to reenter the data again.
Is there any way to make a snapshot of the webview and load it when Navigating back to MainPage.xaml?
I have tried the NavigationHelper, but in the onNavigatingFrom event from MainPage when i try to save the Frame.Content, its the Page2 the one being passed in the NavigationEventArgs.
Any ideas?
One way to do it is to never leave the page. To do this, create two grids. One for the webview and one for the other view. When the page loads, show the first grid and hide the second grid. When you want to show the second view hide the first grid and show the second.
I have used this method in several apps on the phone and windows store and you can simulate popups this way as well.

Delphi, chromium, tabs and flash trouble

So I have this project in which I need to have few tabs (TPageControl) with flash pages running and grab a screenshot of them from time to time without switching active tab.
First I tried TChromiumOSR but the flash is not visible in it, kind of works if I click on a page's button that opens a popup with flash maximized. so it doesn't look like a problem with flash but rather with frames or sth. anywas a no-go.
then I've tried TChromium, everything works alright but I don't know how to grab a screenshot of a control that is on non-active TTabSheet without switching tabs.
using latest dcef3 trunk
any ideas? thanks
edit: It turned out that flash not being visible in OSR is an old chromium bug. It's actually playing but not visible if embedding code has "wmode" set to something else than 'transparent'. I've managed to change that property through js. To actually see the change, flash object needs to be removed from DOM and added again:
chr1.browser.GetFrame(str[i]).ExecuteJavaScript('document.getElementsByName("wmode")[0].value="transparent";', '', 0);
chr1.browser.GetFrame(str[i]).ExecuteJavaScript('document.getElementsByName("wmode")[1].value="transparent";', '', 0);
chr1.browser.GetFrame(str[i]).ExecuteJavaScript('var wtf = document.getElementById("gameApp2");', '', 0);
chr1.browser.GetFrame(str[i]).ExecuteJavaScript('document.getElementById("gameApp2").remove();', '', 0);
chr1.browser.GetFrame(str[i]).ExecuteJavaScript('document.body.appendChild(wtf);', '', 0);
If the tab is not being shown (it's not the front one), it doesn't get drawn (this is an operating system thing). If it's not being drawn, there's nothing there for a screenshot to capture.
If your requirement is to capture a Flash page without it being displayed, you're going to have to find another way to do it.
Assuming your Chrome is still based on WebKit, I know WebKitGTK has its own snapshot engine, if it carries down deep enough, perhaps you can tap into that for your captures.
At one point, there was a behavioural issue with TPageControl that until a tab had been selected, none of its children had valid handles created. I do not know if that is still the case, but if it is, it may complicate your desire to not switch tabs.
Assuming the control HAS a valid window handle, you might create a TBITMAP, lock its canvas, grab the Canvas's handle (DC) and fake a WM_PAINT to the control to get it to render to your bitmap.

How to refresh a app without quitting to apply localization in Sencha Touch 2

When the use selects a different language in a settings screen, I want the app to re-launch so that the navigation and the content is refreshed-reloaded. I currently am forcing this by handling the show method on each class which is not ideal and highly repetitive. This approach does not work for refreshing the tab panel which is always present and there is no event where I can trigger a reload of its content (at least not that I understand).
Ideally I would like the entire app to reload once the user selects a different language and be in a state as if after initial launch. Is there an easy way to accomplish this?
What's worked for me has been:
window.location.reload();
It'll reload the entire app without the user having to relaunch the app from the home screen. Assuming you're working in a webview, all of the window commands work as they would in the browser.
setTimeout(function() {
window.location = 'index.html';
}, 1800);
1800 time line to restart

iPad Home Screen App refreshes on every open

I'm writing a web app for the iPad using HTML5 and SenchaTouch. The app uses cache manifest to function offline. Once it has been added in the home screen and opened without Safari, it will refresh itself every time it is opened, even if just navigating to the home screen and back. The desired behavior is to leave the app, do something else, and then come back to the app with everything untouched.
An example of a similar app that displays the same (undesired) behavior can be found here: http://ignitedmediadesign.com/WebApp/index.html
I've read that using a cache manifest should have solved this problem on iPhone ( http://www.stevesouders.com/blog/2011/06/28/lack-of-caching-for-iphone-home-screen-apps/ ), but doesn't seem to have done the trick for either iPhone or iPad.
Is there another way to fix this? Is there some secret to cache manifest files that stops this that I may have missed?
I'm under the impression this is simply the nature of the "home screen" web apps that operate outside of normal Safari. I have an app that operates just fine in Safari with some minimal state saving, but the blasted non-Safari version refreshes every time. EDIT: Even the showcased O’Reilly example that uses a cache manifest reloads every time when added to the home screen.
You may want to look into creating "routes" (URL fragments) that point to a controller/action pair. Look into the MVC PhoneGap example (If not using PhoneGap, you can scroll past all of that stuff and implement your own data model and store). Also see this Sencha Touch MVC tutorial.
Also, most of the rendered sencha touch components seem to maintain state between changes of the active item. For example. I have a main TabPanel that contains all sub panels. When switching between tabs on the main TabPanel's TabBar, each sub panel maintains its rendering, unless I've set a listener or controller action to do otherwise.
Hope this helps.

Resources