How to intersect with any sprite of a certain cast member?

Hi. I am trying to script a simple 2d platformer engine for a larger University project. I have movement sorted with W and A and gravity. I can get collision detection with the floor by doing
if sprite 1 intersects sprite 2 then
     gvGrav = 0
end if
Sprite 1 is the player and sprite 2 is an instance of the cast member called ground. How would I get this to work with any sprite that is ground? Ill paste the full code below.
global gvRight
global gvLeft
global gvGrav
global gvDown
on enterFrame
  -----------MOVE LEFT---------------------
  if keyPressed("a") then
    sprite(4).locH=sprite(4).locH+gvLeft
    _movie.updateStage()
    gvLeft = gvLeft - .5
    if gvLeft < - 15 then
      gvLeft = -15
    end if
  end if
  if not keypressed("a") then
    gvLeft = 0
  end if
  -----------MOVE RIGHT--------------------
  if keyPressed("d") then
    sprite(4).locH=sprite(4).locH+gvRight
    _movie.updateStage()
    gvRight = gvRight + .5
    if gvRight > 15 then
      gvRight = 15
    end if
  end if
  if not keypressed("d") then
    gvRight = 0
  end if 
  -----------GRAVITY-------------------------
  gvGrav = gvGrav
  sprite(4).locV=sprite(4).locV+gvGrav
  _movie.updateStage()
  gvGrav = gvGrav +.5
  if gvGrav > 30 then
    gvGrav = 30
  end if
  -------------GravityCollision----------------------
  if sprite 4 intersects sprite 1 then
    gvGrav = 0
  end if
  if sprite 4 intersects sprite 2 then
    gvGrav = 0
  end if
end if

I dare say there's a better way to do this, but an easy way is to set a global variable, do a sendallsprites message, and check the global variable again.
So, if you had an extra global in your man control script:
global hitman
then in your collision checking part you would say this:
  hitman = false
  sendallsprites #checkcollision 4
  if hitman = true then
    gvGrav = 0
  end if
The #checkcollision message would get sent to all sprites, and if you had a behavior placed on the floor sprites, that was like this:
global hitman
property mysprite
on beginsprite me
  mysprite = the spritenum of me
end
on checkcollision me,s
  if sprite s intersects sprite mysprite then
    hitman = true
  end if
end
any one of those sprites that intersected with the sprite you ask about would then change the global 'hit man' variable to be true. To make a sprite behave like floor, you would just attach that behavior script.
Notice how the floor sprite makes a note of its sprite number when it first shows up on the stage, you could do the same with your other script, if it's attached to the man character. Then you wouldn't have to have it hard coded to '4', which would save some headaches later if you have to change the sprite layers.

Similar Messages

  • TS1702 i want to know how do blutooth with any mobile can iphone do it or not?

    how i can do bluetooth with any mobile ican do it or ........ ?

    No. You can not pair it with another phone. Bluetooth is for use with hands free devices, A2DP audio streaming, and keyboards. Some apps can use bluetooth peer to peer. You can use bluetooth for tethering if you subscribe to a plan that supports the personal hotspot feature.
    Here is a list of supported bluetooth profiles: http://support.apple.com/kb/HT3647

  • How to deal with any UDDI in SOA Suite 11g?

    Hi folks,
    I have spent quite some time trying to understand how Oracle is dealing with the UDDI aspects in the Soa Suite 11g.
    Back to Oracle AS 10g, I remember, even though i had never used it, that the UDDI repository was a out of the box capability with a very nice Web UI to browse the services The Aqualogic Service Bus seems to have features to consume/publish web services in any UDDI, but no real embedded UDDI in its core.
    Since 11g, obviously the way to go is to adopt Oracle Service Registry. There is a seamless integration with JDeveloper 11g (i.e create a UDDI connection to publish/consume/search web services).
    My company is keen to go on a open source UDDI and I came to the conclusion that any of those (i.e jUDDIv3.02, OpenUDDI) are actually able to work properly with JDeveloper 11.1.1.2. I got XSD exception or other cabalistic errors that definitely show that JDeveloper 11g can only deal with Oracle Service Registry. I heard that the Soa Suite 11g could only deal with UDDI v2 and v3. CentraSite does fit those requirements but does not work too.
    Why is that ? How can I set up my SOA initiative without having the choice on the UDDI ? Does this have changed since PS2 ? I have tried to look up on Metalink and I got a hit on jUDDI but it does clearly state that jUDDI works well now with JDeveloper.
    Any answer on that would be highly appreciated.
    Kind regards,

    Hi,
    DVM cache policy is lazy load. there is no option to preload the cache with server startup currently. However this would be affecting only the first request the susequent requests are serviced from cache.
    HTH..
    appologies for reaching on this late.
    regards,
    Jitendra

  • How to calling with any file format

    Dear experts
    i want to know how i can call to file like doc,xls,htm or any file format ,, from form  by when button pressed
    regards to all....

    Start here:
    http://blogs.oracle.com/shay/entry/10_commandments_for_the_otn_fo
    Then consider something like this if the client machines are Windows:
    Declare
         my_cmd varchar2(512);
    Begin
         -- Item :t1 would be the path and file name to open.
         -- For example: C:\myDirectory\hello.doc
         -- If the path or name includes spaces, you will have to
         -- add quotes around the entry.
         my_cmd := 'rundll32 shell32,ShellExec_RunDLL '|| :t1;
         HOST(my_cmd);
    End;If you are running on the web you will need something like WebUtil which is not available for Forms 6

  • BPC link with any other SAP products?

    Hi, Prakash
    I am wondering how BPC communicate with any other SAP products? using RFC? Can we load the data from ECC into BPC?
    Thanks
    C.S.

    Hi Chimei,
    We are currently going to kickstart our BPC project.
    We went through the process of evaluating products which can help easy extraction of data from SAP products into Outlooksoft.
    There is a company called ERPLink which has a product suite called iNet.BI which helps enable this. It is very inexpensive (17K for software with 17% annual maintenance charges). This product is SAP certified and has ability to read metadata from SAP modules. It can extract data from BW environments (Cubes, queries of ODS objects) and from R/3 environments (via ABAP report programs with their embedded macros & direct table views). From the product demo, the user interface seemed simplistic. The product is installed on the Outlooksoft environment and uses SQL*Server Information Services (DTS packages) to do the load from SAP source system to Outlooksoft.
    You might want to consider this product as an alternative to Flat File loads.
    Hope this helps.
    Regards,
    Abhay Shanbhag

  • In my Apple Macbook Air, most of the USB Flash/Thumb Drives are not shown in the Finder Window. Only a few Brands of USB /Flash Thumb Drives are shown or compatible or shown in the Finder. How do I use any Flash/Thumb Drive with my Apple MacAir?

    In my Apple Macbook Air, most of the USB Flash/Thumb Drives are not shown in the Finder Window. Only a few Brands of USB /Flash Thumb Drives are shown or compatible or shown in the Finder. How do I use any Flash/Thumb Drive with my Apple MacAir?

    Yes, junker thumb drives pour like rain in the market.  
    Which makes are working on your Air, and which arent?
    Stick to Sandisk and a couple of other reliable mfg. of memory sticks

  • I am getting this error message when trying to get to a college webpage Firefox doesn't know how to open this address, because the protocol (html) isn't associated with any program.

    I am trying to get to a college webpage for information and get this error message from firefox Firefox doesn't know how to open this address, because the protocol (html) isn't associated with any program.
    == This happened ==
    Every time Firefox opened
    == whe trying to access webpage

    Is this coming from a link, or from something you are trying to type in the address bar?
    Try replacing the "html" at the start with "http",
    so if you have html://somesite.edu,
    change it to http://somesite.edu.

  • I have an old mpg video file, taken with a very early model "smart phone", that opens and plays fine in my newly "rebuilt" iPhoto library. I cannot open, edit it or share it with any other software. How can I fix it, to be able to do anything with it?

    I have an old mpg video file, taken with a very early model "smart phone", that opens and plays fine in my newly "rebuilt" iPhoto library. I cannot open, edit it or share it with any other software. How can I fix it, to be able to do anything with it?
    Detail:
    I've recently purchaced a 4TB Thunderbolt drive to store my "vast" music and photo libraries. iPhoto had an issue reading the moved library, so I bought and used iPhoto Library Manager to "rebuild" it. Apart from much of the original data such as date taken & camera used etc, it appears to be working well. The aforementioned mpg video was taken some 9 years ago, using an early model "iMate" smart phone, and opens and plays fine on iPhoto, but I cannot open it with anything else, (I've tried iMovie, VLC players, Wondershare and Handbrake) nor can I share it. I just want to edit it, and share it with family.
    Any help would be appreciated...

    No - not iMovie, VLC, Wondershare or Handbrake... Quick time starts with a "CONVERTING", then I get
    I've looked at the "tell me more" links, tried downloading some of the movie players there. I'm begining to think the file is corrupt.
    Thanks for getting back to me again though - appreciate it...

  • When I try to open a video from the website Youtube I got this message that I didnt before I uograde to Firefox 7.0.1 : "Firefox doesn't know how to open this address, because the protocol (rtsp) isn't associated with any program."

    When I try to open a video from the website Youtube I got this message that I didnt before I uograde to Firefox 7.0.1 : "Firefox doesn't know how to open this address, because the protocol (rtsp) isn't associated with any program."
    That didnt happen before until I made an upgrade to 7.0.1

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Tools > Options > Privacy > Cookies: "Show Cookies"

  • Hello,  my ipad has never been paired with any computer.  My PC is ready to die and iTunes will not upload on it.  My iPad is insisting that I connect to iTunes and I can't get out of that screen.  How can I use my iPad without syncing it to iTunes?  Than

    Hello,
    My iPad 2 has never been "paired" with any PC.  My one and only PC is corrupted and will not, after many many attempts, download iTunes.  When I turn on my iPad it insists that I connect to my iTunes.  How can I avoid this and just get the iPad to work like normal?  Any help is much appreciated

    You cannot do anything with the iPad until you do as instructed by the iPad and connect to iTunes on a computer.
    You probably need to restore the iPad and the only way to do that is via iTunes on a computer.
    Take it to an Apple Store and ask for help at a Genius bar or take it to a friend's house that is running iTunes on their computer and try to restore it.
    You will lose all of your data and settings now because you never backed the iPad up in the past.

  • I have a brand new macbook with microsoft office loaded. I set outlook as the default mail. i would rather go back to mac mail but can't figure out how to do it. any ideas?

    I have a brand new macbook with microsoft office loaded. I set outlook as the default mail. i would rather go back to mac mail but can't figure out how to do it. any ideas?
    Thanks for any help
    Lou

    I have a similar problem: I switched from mac mail to Outlook 2011 as the default client, and want to switch back. Mailto links (eg from browser etc) default to Mail.  However, when I try to email a Word document as an attachment, it continues to open Outlook.  Outlook has a button in its prefs for making it the default client, but I don't see a way to turn this pref off in either Outlook or in Word.  

  • HP Protect tool password manager not working with the new version of Mozilla: I got this alert: "Firefox doesn't know how to open this address, because the protocol (dpql) isn't associated with any program." please help

    I have an HP ProBook 4520s. I have been using HP Protect tool's Password manager to store and manage my passords for all Login websites in Firefox 3.6. As a result, I just swiped my fingerprint to log on to any website.
    After I installed the version 4 of Firefox, my all my login details do not work anymore. I have tried to reset them but I repeatedly get this error: "Firefox doesn't know how to open this address, because the protocol (dpql) isn't associated with any program."
    something like this would have been passed onto the address: "dpql://c:\program%20files%20(x86)\hewlett-packard\hp%20protecttools%20security%20manager\bin\dpminionlineids.dll/qlinkload.htm#id=2".
    Although the password manager works with Internet Explorer 9, I need it to work with Firefox 4 as this is my preferred browser.
    Please help. Thank you!

    I guess this means that IE is more user friendly for HP Password Manager finger swipe recall of passwords, a favorite of mine. I still don't see a post from Firefox as to why they haven't produced fix. So I'll switch to IE until things change. I don't see value in downgrading to a Firefox version that's no longer going to be supported.

  • I downloaded Newest mozilla yesterday, adobe updated, and now when I click a YouTube video I get a box saying "Firefox doesn't know how to open this address, because the protocol (rtsp) isn't associated with any program." and can't watch any videos?

    I downloaded the latest version of Mozilla Firefox yesterday, full and complete, and I am actually using it right now. The only problem I have had is upon clicking any YouTube video, the box pops up saying "Firefox doesn't know how to open this address, because the protocol (rtsp) isn't associated with any program." But there are no directions or suggestions on how to address this problem. Ive looked at YouTube add-ons and none of them really seem related. Upon the finish of the new Mozilla, I also was prompted to upgrade the flash player, and did so without any trouble. I am only guessing this is an extension/plug-in problem. I really am quite confused!

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Tools > Options > Privacy > Cookies: "Show Cookies"

  • Frustration! I have all igoods in order to use all, fully as should be. But looks like Softbank does no agree with any connection between iPhone and iMac... What in the world! How Apple let that happen???

    I live in Japan,
    I have all igoods in order to use all, fully as should be. But looks like Softbank does no agree with any connection between iPhone and iMac... What in the world! How Apple let that happen??

    Make sure that you allow pages to choose their colors and that you haven't enabled High Contrast in the Accessibility settings.
    *Firefox > Preferences > Content : Fonts & Colors > Colors : [X] "Allow pages to choose their own colors, instead of my selections above"
    See also:
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    *https://support.mozilla.org/kb/Images+or+animations+do+not+show

  • I have installed HP2035n. But when i try to open the embedded web server, i get the error "Firefox doesn't know how to open this address, because the protocol (fe80) isn't associated with any program." What is the possible solution?

    I have installed HP2035n. But when i try to open the embedded web server, i get the error "Firefox doesn't know how to open this address, because the protocol (fe80) isn't associated with any program." What is the possible solution?
    I typed in the IPv6 address of the printer in the address feild of firefox.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    Do a malware check with some malware scanning programs.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br />
    * http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    * http://www.superantispyware.com/ - SuperAntispyware
    * http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    * http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    * http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    * "Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

Maybe you are looking for