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

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........... :)

Related

Game Center Matchmaking Custom Invites

I'm sure theres a 'simple' answer to this, but I've been having a difficult time finding it.
I've created an iOS card game that works in game center. At the moment, it determines the online players automatically and works fine.
What I want to do is have the user invite their game center friends to play. The documentation isn't really helping me.
I'm doing my project in swift, and I feel like I'm dealing with deprecated items and old documentation here?
I've managed to get the users list of friends and then I assume I need to instantiate a matchmaker with that list of friends.
What I'm stuck at, is trying to implement the "RecipientResponseHandler" code as per apple's guidelines:
request.recipientResponseHandler = ^(GKPlayer *player, GKInviteeResponse response)
{
[self updateUIForPlayer: player accepted: (response == GKInviteeResponseAccepted)];
};
Question 1: First of all, What does the ^ symbol represent in the swift language?
Question 2: XCode doesn't seem to like the * symbol in the arguments...I've tried doing things like...
request.recipientResponseHandler = (player: GKPlayer, response: GKInviteeResponse){
print("Do codeStuffHere")
};
But, I can't find a way of wording this that XCode will allow...
Question 3: How can I write this response handler to get it to work?
Question 4: Also,to listen for invites, I need to implement the GKLocalPlayerListener protocol...Anything else?
Question 5: I feel like I'm missing something glaring?
I've been learning on my own, and sometimes it takes a while to understand concepts without any direction, so please go easy on me internet. I'm just starting to understand completion handlers and closures...
Thanks in advance for any help.
What does the ^ symbol represent in the swift language?
XCode doesn't seem to like the * symbol in the arguments.
That's because that code is written in Objective-C, not Swift.
I'm assuming you're looking at the documentation for GKMatchRequest (update as of Jan 2023: It seems Apple has removed the code listing from this page at some point).
If so, then yeah, Apple just hasn't gotten around to updating all their documentation to use Swift instead of Objective-C (even on pages where the language selected is Swift, like this one).
Here's the Swift equivalent of that entire code listing:
func invite(friends: [GKPlayer]) {
let request = GKMatchRequest()
request.minPlayers = 2
request.maxPlayers = 4
request.recipients = friends
request.inviteMessage = "Your Custom Invitation Message Here"
request.recipientResponseHandler = { player, response in
self.updateUI(for: player, accepted: response == .accepted)
}
}
func updateUI(for player: GKPlayer, accepted: Bool) {
// update your UI here
}
For question 4, be sure to register the GKLocalPlayerListener and only register once, for example:
GKLocalPlayer.local.register(self)

ios11 game center find player fails

I am developing a multi player game. I want to use "standard" GKMatchmakerViewController for finding players like this:
let matchrequest = GKMatchRequest()
matchrequest.minPlayers = 2
matchrequest.maxPlayers = 2
matchrequest.defaultNumberOfPlayers = 2
matchrequest.inviteMessage = "Hello, do you want to play with me ?"
let mmVC = GKMatchmakerViewController(matchRequest: matchrequest)
mmVC?.matchmakerDelegate = self
self.present(mmVC!, animated: true)
If I invoke the GKMatchmakerViewController on both devices and press "Play now" they find each other and everything ist fine.
However when I press "Invite Friends", press the "+" on the right to add a recipient and go then to the tab "Nearby" NO players show up.
Q1: Why don't I see the player in "Nearby" but can connect to it by pressing "Play now"
Q2: If I send an invitation to my other player via iMessage the message is received on the other device and when I click it the app gets launched. But it remains at its Main Screen and doesn't take any action to respond to the invitation. What Protocol or Callback needs to be implemented in order to react to app launches caused by "game invitations" ?
Please refer to the latest API. The GC APIs have changed dramatically and most SO answers refer to the deprecated API.
Thanks
Chris
For Q2. you need to implement GKLocalPlayerListener to answer calls.
How were you able to send invites? I'm trying to figure out how to get a GKPlayer from a string. Like If I want to send an invite to my friend "Blazing420" how do I know his GKPlayer ID or how do I find him, since GKMatchRequest.recipients only takes GKPlayers as arguments.

Flex AS3 Iphone - How to Open Native Maps Application?

I have a bunch of buttons that opens the default map application and puts something in the users system clipboard. It works fine on Android tablets, but the Iphone does nothing when the button is clicked. Here is the code:
case "MapYummyYummy":
System.setClipboard( "1665 Stelton Rd Piscataway Nj 08901" )
_callURL = "geo: 40.4978922, -74.4488224";
var targetURL:URLRequest = new URLRequest(_callURL);
navigateToURL(targetURL);
break;
Does anyone know the equivalent for this that will work on Iphone devices? thanks!
Have you tried this setData method? (I have no experience with this one, but looks like a viable alternative).
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard.html#setData()
iOS launch maps via URL reference:
http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html
Querying for a location:
http://maps.apple.com/?q=cupertino
setting a start and end for directions:
http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino
Hope it works for ya (looked up not tested).

Corona: how to capture a screen in corona?

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.

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