corona

how to make multiple objects bounce around in Corona sdk

纵然是瞬间 提交于 2019-12-13 04:35:41
问题 Hey guys I am new to Corona sdk and would like some help with make some balls to bounce around the screen randomly, I don't know the code for this so could someone give me a piece of code that would make the balls bounce randomly around the screen with out stopping or anything. Also when they hit the wall the ball would go in opposite direction. Thanks for you help I thank you a million. I tried this but it don't work if(ball.x < 0) then ball.x = ball.x + 3 xSpeed = -xSpeed end--Left if((ball

Corona string.find() : Finding “.”

旧巷老猫 提交于 2019-12-13 04:32:11
问题 I'm trying to split a string into two parts, which is divided by a '.' character. But string.find() function cant handle that I have this kind of string local test = "345345.57573" I tried local start = string.find( test, "." ) local start = string.find( test, "\." ) local start = string.find( test, "(%w+).(%w+)" ) But none of them worked. String.find() always return 1 which is false. What might be the problem? Edit: I also tried to use gsub and change . with another character but it didn't

Tried debugging. Still dont know why the code is not working

*爱你&永不变心* 提交于 2019-12-13 02:56:40
问题 I am currently making a Simon Says game, and it seems that when it runs through my algorithm, it doesn't fully complete it. I have tried debugging the problem, and found out WHERE the source of the problem is, but I am not sure what to fix exactly. I am using Corona sdk, Lua as my language. Before this function, I have stated light = 2. It is supposed to decrement light by 1 each time until it is <= 0. After, it is supposed to run that Boolean expression, but it is not. Here is part of my

Reloading a game with corona sdk

心已入冬 提交于 2019-12-13 02:11:37
问题 I am creating my first iPhone game and cannot figure out how to reload my game. I am using coronaSDK and have tried to use their composer API. When the player dies a button with "play again" appears and when he touches it I direct him to a scene called "reload.lua" with composer.gotoScene("reload") . In this scene I have the following code: function scene:show(event) local sceneGroup = self.view local phase = event.phase if (phase == "will") then elseif (phase == "did") then local replay =

how do i have one physics body negate the collision of another.

不想你离开。 提交于 2019-12-13 01:39:13
问题 i have two images on the screen that overlap called A and B. i have a third image called C that the user is able to move around the screen. the bigger one (A) of the two resets the C to the spawn point on collide. i need to know how to make it so that C can walk over image B and not be reset to the spawn point. as in image B overlaps image A and negates the collision function. here is the code: --Hides status bar from top of page display.setStatusBar( display.HiddenStatusBar ) --Set a test

Lua OOP grid class with event

我的未来我决定 提交于 2019-12-13 01:27:24
问题 I'm learning lua and i'm trying the OOP approach. To start, I'm trying to make a grid class, but I think i'm still lacking some knowledge to make it do what I want it to do. This is my code so far: local screen = require( 'data.screen') Grid = {} Grid_mt = { __index = Grid } --- Constructs a new Grid object. function Grid:new( params ) local self = {} local function try( self, event ) print(self.empty) end for i = 1, screen.tilesAcross do if not self[i] then self[i] = {}; end for j = 1,

Different layers in Corona/Lua

时光总嘲笑我的痴心妄想 提交于 2019-12-12 19:02:19
问题 I've got a question about layering images/buttons with Corona/Lua. If I create one button on top of another one and then click it, both buttons' events are triggered. How do I prevent this? Thanks, Elliot Bonneville EDIT: Here's how I create the buttons: button1 = display.newImage("button1.png") button1:addEventListener("tap", Button1Call) button2 = display.newImage("button2.png") button2:addEventListener("tap", Button2Call) 回答1: Return true from the event handling function. Touch events keep

Find close path or region using recursive method

こ雲淡風輕ζ 提交于 2019-12-12 17:15:39
问题 I have a object in 2d array and i want to traverse through them top, left, right for that object acutally i want to check if there are making some loop or better making some closed region. See this picture for better explanation. Acutally i have a X x Y of slot and when user touch on any of the region it adds the brick there so what i want to do is every time user add a brick check if it is making a close path. I have writen recursive function for that but it's not working fine it always go

Stop event propagation in Corona SDK

五迷三道 提交于 2019-12-12 13:47:37
问题 I'm using Corona SDK, and Director 1.4 to create an app. My goal is to open a popup when the button ( btn_play ) is clicked. However, I encounter a problem. When the btn_play is clicked, it triggers openPopup(e) as well as changeScene(e) (as the background is set to execute the function). How can I stop the function changeScene(e) from executing when clicking the btn_play button? Here is my game screen's codes: module(..., package.seeall) local localGroup function new() localGroup = display

Lua gmatch odd characters (Slovak alphabet)

元气小坏坏 提交于 2019-12-12 11:04:10
问题 I am trying to extract the characters from a string of a word in Slovak. For example, the word for "TURTLE" is "KORYTNAČKA". However, it skips over the "Č" character when I try to extract it from the string: local str = "KORYTNAČKA" for c in str:gmatch("%a") do print(c) end --result: K,O,R,Y,T,N,A,K,A I am reading this page and I have also tried just pasting in the string itself as a set, but it comes up with something weird: local str = "KORYTNAČKA" for c in str:gmatch("["..str.."]") do