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

  • SEARCH
  • Home
  • 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 9161793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:03:14+00:00 2026-06-17T14:03:14+00:00

I have multiple objects and multiple containers, My plan is that any object can

  • 0

I have multiple objects and multiple containers, My plan is that any object can be dropped on any container, but once a container has an object dropped on it, I want it to be occupied and not allow any more objects on to it. Is there an isOcuppied call or something like that, I cant find any examples of this.

    local function onTouch( event )
local t = event.target

local phase = event.phase
if "began" == phase then
    -- Make target the top-most object
    local parent = t.parent
    parent:insert( t )
    display.getCurrentStage():setFocus( t )


    -- Spurious events can be sent to the target, e.g. the user presses 
    -- elsewhere on the screen and then moves the finger over the target.
    -- To prevent this, we add this flag. Only when it's true will "move"
    -- events be sent to the target.
    t.isFocus = true

    -- Store initial position
    t.x0 = event.x - t.x
    t.y0 = event.y - t.y
elseif t.isFocus then
    if "moved" == phase then
        -- Make object move (we subtract t.x0,t.y0 so that moves are
        -- relative to initial grab point, rather than object "snapping").
        t.xScale = 1.7
        t.yScale = 1.7
        t.x = event.x - t.x0
        t.y = event.y - t.y0
        --t1 = t1..t.value
    elseif "ended" == phase or "cancelled" == phase then
    for i = 1, #posX do
     if (((t.x >= ((sizeX/2) + posX[i] - ((2/3) * sizeX))) and (t.y >= ((sizeY/2) + posY - ((1/3) * sizeY))) and (t.x <= ((sizeX/2) + posX[i] + ((2/3) * sizeX))) and (t.y <= ((sizeY/2) + posY + ((1/3) * sizeY)))) or ((t.x >= ((sizeX/2) + posX[i] - ((1/3) * sizeX))) and (t.y >= ((sizeY/2) + posY - ((2/3) * sizeY))) and (t.x <= ((sizeX/2) + posX[i] + ((1/3) * sizeX))) and (t.y <= ((sizeY/2) + posY + ((2/3) * sizeY)))) or ((t.x >= ((sizeX/2) + posX[i] - ((1/2) * sizeX))) and (t.y >= ((sizeY/2) + posY - ((1/2) * sizeY))) and (t.x <= ((sizeX/2) + posX[i] + ((1/2) * sizeX))) and (t.y <= ((sizeY/2) + posY + ((1/2) * sizeY))))) then
        t.x, t.y = posX[i] + (sizeX/2), posY + (sizeY/2);
     elseif  (((t.x >= ((sizeX/2) + posX1[i] - ((2/3) * sizeX))) and (t.y >= ((sizeY/2) + posY1 - ((1/3) * sizeY))) and (t.x <= ((sizeX/2) + posX1[i] + ((2/3) * sizeX))) and (t.y <= ((sizeY/2) + posY1 + ((1/3) * sizeY)))) or ((t.x >= ((sizeX/2) + posX1[i] - ((1/3) * sizeX))) and (t.y >= ((sizeY/2) + posY1 - ((2/3) * sizeY))) and (t.x <= ((sizeX/2) + posX1[i] + ((1/3) * sizeX))) and (t.y <= ((sizeY/2) + posY1 + ((2/3) * sizeY)))) or ((t.x >= ((sizeX/2) + posX1[i] - ((1/2) * sizeX))) and (t.y >= ((sizeY/2) + posY1 - ((1/2) * sizeY))) and (t.x <= ((sizeX/2) + posX1[i] + ((1/2) * sizeX))) and (t.y <= ((sizeY/2) + posY1 + ((1/2) * sizeY))))) then
        t.x, t.y = posX1[i] + (sizeX/2), posY1 + (sizeY/2);
        t2[i] = t.value
        --t1 = t1..t.value
     -- elseif  (((t.x >= ((sizeX/2) + posX2 - ((2/3) * sizeX))) and (t.y >= ((sizeY/2) + posY2 - ((1/3) * sizeY))) and (t.x <= ((sizeX/2) + posX2 + ((2/3) * sizeX))) and (t.y <= ((sizeY/2) + posY2 + ((1/3) * sizeY)))) or ((t.x >= ((sizeX/2) + posX2 - ((1/3) * sizeX))) and (t.y >= ((sizeY/2) + posY2 - ((2/3) * sizeY))) and (t.x <= ((sizeX/2) + posX2 + ((1/3) * sizeX))) and (t.y <= ((sizeY/2) + posY2 + ((2/3) * sizeY)))) or ((t.x >= ((sizeX/2) + posX2 - ((1/2) * sizeX))) and (t.y >= ((sizeY/2) + posY2 - ((1/2) * sizeY))) and (t.x <= ((sizeX/2) + posX2 + ((1/2) * sizeX))) and (t.y <= ((sizeY/2) + posY2 + ((1/2) * sizeY))))) then
        -- t.x, t.y = posX2 + (sizeX/2), posY2 + (sizeY/2);
    end
    end
        t1 = t1..t.value
        t.xScale = 1
        t.yScale = 1
        --print(tile.label)
        display.getCurrentStage():setFocus( nil )
        t.isFocus = false
        --n = n + 1
        --value = " "
    end
end

Here is my code as it stands, Also Im I have a value attached to each tile e.g tile a = “A”, currently I’m just appending a string each time a tile is moved, but I want the string or maybe use a table to only be appended when the tile has been put in a container. For example if one letter is in the wrong place and I move it to the right place I have touched it twice so my final string will be wrong

  • 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-06-17T14:03:15+00:00Added an answer on June 17, 2026 at 2:03 pm

    Why not set a value on your container:

    myContainer.isOccupied = false
    

    Then in your event handler, when every you get to your ended phase you can simply do a check:

    if not myContainer.isOccupied then
        -- code to drop
        myContainer.isOccupied = true
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that I want to contain multiple objects of something I
I have been attempting to have a object that I can use across multiple
I want to represent clubs which have multiple members (each member can also join
I have a container object that is templatized. I am trying to make a
Inside a container object, I have created a class Factory , that is responsible
We have a number of plugin applications that can all run independently but also
I have object A which contains multiple instances of object B, which in turn
I have multiple objects moving about in a 3D space and am looking for
I have multiple NSURLConnections running providing data back to the delegate objects. Is it
I'd like to have multiple versions of an object with different access modifiers on

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.