corona

How to isolate non english words separated by spaces in Lua?

自闭症网瘾萝莉.ら 提交于 2019-12-11 01:49:18
问题 I have this string "Hello there, this is some line-aa." how to slice it into an array like this? Hello there, this is some line-aa. this is what I have tried so far function sliceSpaces(arg) local list = {} for k in arg:gmatch("%w+") do print(k) table.insert(list, k) end return list end local sentence = "مرحبا يا اخوتي" print("sliceSpaces") print(sliceSpaces(sentence)) this code works for English text , but not for arabic, how can I make it work for arabic too? 回答1: Lua strings are sequences

Update the target coordinates while transitioning

泪湿孤枕 提交于 2019-12-11 01:18:35
问题 I am making a game in corona and I am facing a problem. I have a circle on screen and I want it to follow the touch coordinates continuously. I am using transition.to function to do so but the thing is, whenever this function get a coordinate, it completes the transition even if the coordinates are updated during the transition. if event.phase == "began" or event.phase == "moved" then follow = true touchX = event.x; touchY = event.y elseif event.phase == "ended" then follow = false end And in

Automatically change the position of objects when using different devices

时光总嘲笑我的痴心妄想 提交于 2019-12-10 23:45:32
问题 I am still new to lua and corona (3 days to be exact) and I'm trying to my objects on the screen using multiple devices. From what I understand, to make the objects automatically reposition themselves, I need to get the screen size and do some calculation to it to make the necessary adjustment. Here's a sample of what I'm trying to do: obj1 = display.contentWidth*0.50 This will then put my object to the middle of the screen but there are instances wherein this doesn't seem effective so my

Email address validation using corona sdk

两盒软妹~` 提交于 2019-12-10 19:19:05
问题 In my project, a form for the user to fill the details. In that, one text field to enter email id of the user. So i need to validate the email in that text field, in corona project 回答1: Try this regular expression: local email = "email@email.com" if (email:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then print("VALID EMAIL") else print("INVALID EMAIL") end 回答2: Use regular expression pattern for checking email. Use this "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w

jump object on collision

两盒软妹~` 提交于 2019-12-10 19:18:13
问题 I am trying to implement a bar that rebounds the object falling on it. however I just want the object to rebound when it falls on it from above the top edge. if the object is comming from bellow the object should pass as if the bar doesnot exsits. This is similar to what the bird does in tweetjump or doodle does in doodle jump. Any hints on how I can do this in corona ? 回答1: When the object collides with the bar from below, Try giving bar.isSensor = true Have a read here: http://developer

CORONA: timer.cancel() returns “Attempt to index a nil value”

大兔子大兔子 提交于 2019-12-10 18:13:46
问题 I'm trying to cancel a timer started in a "touch event" function inside another "touch event" function, as shown below: local function startNewGame(event) if(event.phase=="ended")then local function animationImmaginiOggetti() for i=1, 7 do transition.to(immaginiOggettiAvvioPartita[i], { time = 200, delay = 0, xScale = 0, yScale = 0, alpha = 0}) end end local function removeImmaginiOggetti() if immaginiOggettiAvvioPartita[1] then for i=1, 11 do immaginiOggettiAvvioPartita[i]:removeSelf()

Can you call “require” on a variable?

Deadly 提交于 2019-12-10 17:32:08
问题 I have a lua file that will require another lua file to run but I can't hard code the file name. Can i use the require function on a variable or do i need to figure out an alternate approach to what i am doing? For example local path = "mypath.txt" local level = require path 回答1: Yes, you can. require "module" is just a syntactic sugar for require("module") that only works if call a function with single argument that is a string or table constructor. Use proper call in form of require(path)

Corona sdk (lua) how to send request to php script for registering a device to get notifications?

六眼飞鱼酱① 提交于 2019-12-10 12:21:50
问题 I am working on an app that requires to get push notifications I couldn't get PushWoosh to work (device logged succesful, but there were no subscribers) so the people I'm working with opted for configuring their own server to send notifications to GCM. The PHP Register code is as follows: require_once('loader.php'); // return json response $json = array(); $nameUser = $_POST["name"]; $nameEmail = $_POST["email"]; // GCM Registration ID got from device $gcmRegID = $_POST["regId"]; /** *

different screen sizes with corona sdk

无人久伴 提交于 2019-12-10 11:11:39
问题 I am making my first iphone game using corona sdk and would like it to run on as many devices as possible (phones + tablets). However I am not sure how to deal with different screen sizes and resolutions. I developed my game for the iPhone 5 using corona simulator and it works fine on that device. When I tried it on lower resolution devices like the iPhone 4 I get 2 black rectangles on each side. I tried creating 2 different backgrounds with different resolutions and added this in my config