Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7401895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:35:56+00:00 2026-05-29T04:35:56+00:00

We’re using objects that do not necessarily need to leverage the physics engine, but

  • 0

We’re using objects that do not necessarily need to leverage the physics engine, but we still need to detect collision. Here’s a similar example to what we’re trying to build:

In solitaire, the cards are draggable objects. When they are released over top of another stack of cards (the collision), they will “stick” to that deck. The target hotspots (the card stacks) are not always known ahead of time – they are dynamic.

What would be the best approach to this problem in Corona SDK?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:35:57+00:00Added an answer on May 29, 2026 at 4:35 am

    If you do not want to use physics engine, you could code up a touch event listener to check for overlapping cards. I assume no difference in a stack of cards or a single card.

    local cards={} --a list of display objects
    cards[1]=display.newRect(100,100,100,100)
    cards[2]=display.newRect(100,210,100,100)
    cards[3]=display.newRect(100,320,100,100)
    
    local tolerance=20 --20px radius
    local cardAtPointer=0  --the index of the card stuck to user hand
    
    local function onOverlap(self,event)
        if event.phase == "began" then
            cardAtPointer=self.index    --hold one card only    
        elseif event.phase == "moved" then
            if cardAtPointer > 0 and self.index == cardAtPointer then
                self.x,self.y = event.x,event.y     --drag card around
            end
        elseif event.phase == "ended" or event.phase == "cancelled" then
            local s=self
    
            for i=1,#cards do
                local t=cards[i]
                if s.index ~= t.index then  --dont compare to self
                    if math.pow(tolerance,2) >= math.pow(t.x-s.x,2)+math.pow(t.y-s.y,2) then
                        print(s.index.." overlap with "..t.index)
                        break   --compare only 2 overlapping cards, not 3,4,5...
                    end
                end
            end
            cardAtPointer=0     --not holding any cards
        end
    end
    
    for i=1,#cards do 
        cards[i].index=i
        cards[i].touch=onOverlap
        cards[i]:addEventListener("touch",cards[i])
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.