Corona: how to capture a screen in corona? - lua

Can anyone suggest how to capture a screen in corona both full screen and particular portion of it?

Try this. It will work :
local function captureDeviceScreen()
local captured_image = display.captureScreen( true )
captured_image:scale(.5,.5)
local alert = native.showAlert( "Success", "Captured Image is Saved to Library", { "OK" } )
end
Runtime:addEventListener("tap",captureDeviceScreen)

A google search produced this link: How to capture a screen in corona
If you are having issues with an implementation then please provide more information and perhaps say what you have tried so far so we know where to go next.

Related

How to get last picture taken by user/camera

How do I get last picture from gallery (camera roll) using flutter?
I would like to display this photo as a thumbnail like this:
I know that it's possible in android Get uri of picture taken by camera and in IOS Swift - how to get last taken 3 photos from photo library?
Is there a tool, lib, media API that could help me with that?
You can try using this library. photo_manager
List<AssetEntity> assets = [];
_fetchAssets() async {
final albums = await PhotoManager.getAssetPathList(type: RequestType.all);
final recentAlbum = albums.first;
final recentAssets = await recentAlbum.getAssetListRange(
start: 0, // start at index 0
end: 1, // end at a very big index (to get all the assets)
);
print(recentAssets);
setState(() => assets = recentAssets);
}
Use platform channels ,, as you know it's native solution
https://medium.com/flutter-io/flutter-platform-channels-ce7f540a104e
https://flutter.io/docs/development/platform-integration/platform-channels
If you're willing to do this through a dialog, you can use the image picker plugin which allows you to go through the camera's image gallery and the user can select the image (including the last image).
If you want this done completely programmatically, someone implemented a pull request for this very feature here: https://github.com/flutter/plugins/pull/676, but it hasn't been accepted because it needs some tests. You could copy the code from that PR, or add some tests, and then get it accepted into the repo!

Trying to set Estimote iBeacon GPIO pin .high - SWIFT iOS

Ive been trying for a few days now to set a pin high (Estimote location beacon) from an app I'm building.
Im doing something wrong as i am getting an error when the block fires off. Error is: [ESTTelemetryInfo portsData]: unrecognized selector sent to instance...
Ive looked everywhere for a snippet but can't find anything. I only want to be able to set the pin high (i don't need to send any data). If i can set the pin high i figure i could set it low when done using the same methods. This is the code:
let telem = ESTTelemetryInfo.init(shortIdentifier: "xxxxxxxxxxxxxxxx")!
let setPinHigh = ESTTelemetryNotificationGPIO.init(notificationBlock: { (telemInfo) in
if telInfo.shortIdentifier! != "xxxxxxxxxxxxxxxx" { return }
telemInfo.portsData.setPort(.port0, value: .high)
})
setPinHigh.fireNotificationBlock(with: telem)
Any help would be greatly appreciated.
ps Sorry if this is incorrectly formatted (long time reader first time poster).
Cheers
Gary
Fixed..we'll sort of. For anyone wanting to know the right way to to set a pin high, in output mode, is to connect to the beacon first through the device manager: ESTDeviceManager() -set the delegate in the class as ESTDeviceManagerDelegate - startDeviceDiscovery(with: deviceFilter) then in the delegate method:
func estDeviceConnectDidSucceed(_ device: ESTDeviceConnectable) { self.settings.gpio.portsData.setPort(.port0, value: .high)
}
BUT -> at the moment there is a bug that portsData has no member 'setPort'. I've filed a bug issue with Estimote on GitHub. Will come back to report once it's fixed.

Corona SDK: show emoji/images on native.showAlert()

I'd like to let a user know on my game that he's won a life by showing some text with a little heart on the end through native.showAlert().
the code for the alert is
native.showAlert( "Hi!", "Thank you for playing! Here's one extra life as a gift for your next game. Enjoy!" , {"OK"}, lifegift )
I want to show a heart after enjoy. How do I do that? It could be either emoji or an image. Thanks
p.s.: only building for iOS for now
Do you simply want to show a heart on your corona SDK alert..?
If you are using a mac, then you can simply do this as:
native.showAlert( "Hi!", "You got an extra ♥ " , {"OK"}, lifegift )
It will look like this:
You can get different symbols from various sites like this.
Keep coding........... :)

Does media.playVideo() work on Corona SDK with windows OS

I'm using Corona sdk, and just learnt the API media.playVideo("myfilename.mp4", true, listener).
When I open a blank file with only the code:
function showSuccess()
print( "success" )
end
media.playVideo( "hummingbird.mp4" , true, showSuccess)
The corona simulator displays nothing on screen, and the output is empty as well. On my android phone the video plays fine.
Question: Can corona simulator handle media.playVideo while i'm using a windows OS?
If not possible on Windows. How can I get around this? On bigger projects I would need the showSuccess function to print "success" in order to debug.
Thank you
Replace your last line by:
media.playVideo( "hummingbird.mp4" , true, showSuccess)
Your current line invokes the showSuccess method directly on the same line, instead of passing it as a function handle.

How To Restart Scenes In Corona SDK?

Am using Corona's SDK storyboard API, in my app I want to let users "try again" the level. I though simply calling
storyboard.gotoScene("level20","flip")
where level20 is the current scene, after an event (taping the "try again" button) would work but the scene keeps all it's display objects in the same place instead of resetting like when I come from a different scene.
Is it possible to restart a scene from the same scene?
Thanks.
Edit:
Am using Corona's Version: 2.0.0, Build: 2011.704
Edit (possible fix):
I might have found the fix. From the docs in the "Scene Purging and Removal": when you go to a new scene the previous scene sticks around in memory for fast reloading, scene:createScene() removes this memory.
So the fix I found was to call scene:createScene(), it seems to work but if this is the wrong approach please let us know. Thanks.
create a 'dummy scene' where u can storyboard.purgeScene("level20") under createScene() then create a function in enterScene() that u can storyboard.gotoScene("level20","flip"). make sure u storyboard.purgeScene ('dummy scene') in ''level'' 20. Your next question will be 'Do I need to create 20 dummy scenes?' No store a variable under storyboard.level = '20' than call it from the 'dummy scene'
Above seemed not work well, I got my solution with simple transition effect.
function scene:refresh(event)
local v = self.view
transition.to(v, {time=500, alpha=0.5, transition=easing.inExpo, onComplete=function(e)
self:destroyScene()
self:createScene()
storyboard.reloadScene()
transition.to(v, {time=500, alpha=1, transition=easing.outExpo})
end})
end
I haven't actually done this myself, but based on the discussion here:
http://blog.anscamobile.com/2011/11/introducing-the-storyboard-api/
It looks like you'll need to call storyboard.purgeScene("level20") before calling storyboard.gotoScene("level20","flip")

Resources