Can anyone help me with a bit of script modifying?

Hey guys, can anyone help me?
Here is some script that makes my character obviously move
and detects walls. I would like to modify the script so that when
my character hits the right keydown, the sprite changes to cast
member "right". I have tried and so far all i have done is succeed
in making the cast member change but this then deactivates the
walls. Any ideas??
on exitFrame me
if keyPressed(123) then
move(me,-5,0)
end if
if keyPressed(124) then
move(me,5,0)
end if
if keyPressed(125) then
move(me,0,5)
end if
if keyPressed(126) then
move(me,0,-5)
end if
end
on move me, dx, dy
oldRect = sprite(me.spritenum).rect
newRect = oldRect + rect(dx,dy,dx,dy)
hitWall = FALSE
repeat with i = 2 to 30
if sendSprite(i,#hitWall,newRect) then
hitWall = TRUE
exit repeat
end if
end repeat
if not hitWall then
sprite(me.spriteNum).loc = sprite(me.spriteNum).loc +
point(dx,dy)
end if
end
Many thanks.

Hi Hayz,
I actually recognise that script.
Try the following:
on exitFrame me
if keyPressed(123) then --left
move(me,-5,0,1)
end if
if keyPressed(124) then -- right
move(me,5,0, 2)
end if
if keyPressed(125) then -- down
move(me,0,5, 3)
end if
if keyPressed(126) then -- up
move(me,0,-5, 4)
end if
end
on move me, dx, dy, directionMove
-- get rect and add change to it
oldRect = sprite(me.spriteNum).rect
newRect = oldRect + rect(dx,dy,dx,dy)
case directionMove of
1: (sprite(me.spritenum)).member = member("character_left")
2: (sprite(me.spritenum)).member = member("character_right")
3: (sprite(me.spritenum)).member = member("character_down")
4: (sprite(me.spritenum)).member = member("character_up")
end case
-- loop through possible wall sprites and detect collisions
hitWall = FALSE
repeat with i = 2 to 30
if sendSprite(i,#hitWall,newRect) then
hitWall = TRUE
-- insert collision instructions here
exit repeat
end if
end repeat
-- if no collision, then move sprite
if not hitWall then
sprite(me.spriteNum).loc = sprite(me.spriteNum).loc +
point(dx,dy)
end if
end
And remember, the sprites that you're colliding with need
their own behavior with:
on hitWall me, objRect
if intersect(sprite(me.spriteNum).rect,objRect) <>
rect(0,0,0,0) then
return TRUE
else
return FALSE
end if
end
regards
Dean
Director Lecturer / Consultant / Director Enthusiast
http://www.fbe.unsw.edu.au/learning/director
http://www.multimediacreative.com.au
email: [email protected]

Similar Messages

  • Can anyone help me with a user login script on php for Oracle database?

    I have a script which somehow is not working well. Can anyone give a good script (for Oracle database) for user login and validation and change password? I will be grateful
    JJZ

    http://www.oracle.com/technology/pub/articles/deployphp/seliverstov_deployphp.html
    http://www.oracle.com/technology/tech/php/htdocs/php-oracle-tutorial.html

  • Can anyone help me with advice for a replacement hard drive

    Hi there,
    Can anyone help me with advice for a replacement hard drive and RAM upgrade for my Mac Book Pro 5,3
    Its 3 years old & running Snow Leopard 10.6.8
    I do a lot of audio & movie work so performance is important.
    The logic board was replaced last summer & I was advised to replace the hard drive then...oops
    Anyway it has limped on until now but is giving me cause for concern...
    I have found a couple of possibilities below...so if anyone does have a moment to take a look & help me out I would be most grateful
    http://www.amazon.co.uk/Western-Digital-Scorpio-7200rpm-Internal/dp/B004I9J5OG/r ef=sr_1_1?ie=UTF8&qid=1356787585&sr=8-1
    http://www.amazon.co.uk/Kingston-Technology-Apple-8GB-Kit/dp/B001PS9UKW/ref=pd_s im_computers_5
    Kind regards
    Nick

    Thanks guys that is so helpful :-)
    I will follow your advice Ogelthorpe & see how I get on with the job!!! Virgin territory for me so I may well shout for help once my MBP is in bits!! Is there a guide for duffers for this job anywhere??
    & yes in an ideal world I would be replacing my old MBP but I'm just not in a position to do that at the moment....let's hope things pick up in 2013
    All the very best
    Nick

  • Can anyone help me with a repeating pattern that is staggered?

    Can anyone help me with a repeating pattern that is staggered and must be aligned perfectly while staggered. Is there a way to do this? I keep staggering it by eyeball and need it to be accurate and each row is offset.
    My art board is 19.25x11.50 I have a repeating logo and name underneath (hard to see) I am setting this up for a print design to go onto tissue paper for insert into a shoe box. Any help is greatly appreciated?
    Thanks,

    Option drag your object horizontally to make a copy or use Move and copy if you need a precise increment. The hit Cmd+D a few times to make duplicates with the same spacing.
    Hit Enter again and make a note of the increment on a piece of paper. Cancel.
    Select everything and use the same increment, now in a vertical direction, to make 2 further copies.
    Take the middle row and move it horizontally by half of the increment. This means that the circles in the middle row are positioned horizontally half way between those in the other two rows.
    Draw your defining rectangle so that its corners are on the centres of those 4 circles. (This gives you its right size but you may possibly need to move it a bit.) Send it to the back of your stack.
    Drag those 8 circles and the rectangle to your Swatches panel.
    (If you’re on Windows read Ctrl instead of Cmd and Alt instead of Option.)

  • Can anyone help me with Magicjack? after I purchased US number I am unable to log in on my Iphone, I keep getting an error "YOUR DEVICE IS NOT ON THIS ACCOUNT" I contacted MJ support but they are very much useless and dont know how to fix it!

    can anyone help me with Magicjack? after I purchased US number I am unable to log in on my Iphone, I keep getting an error "YOUR DEVICE IS NOT ON THIS ACCOUNT" I contacted MJ support but they are very much useless and dont know how to fix it!

    There's a whole lot to read in your post, and frankly I have not read it all.
    Having said that, this troubleshooting guide should help:
    http://support.apple.com/kb/TS1538
    In particular, pay attention to the mobile device support sections near the bottom, assuming you have already done the items above it.

  • Can anyone help me with a problem i am having with my music on my iPhone 4S. I have put alot of Compilation CDs in my library on iTunes. I download these tracks onto my phone, everything is ok so far. Now, this is what is niggling me and I don.t know how

    Can anyone help me with a problem i am having with my music on my iPhone 4S. I have put alot of Compilation CDs in my library on iTunes. I download these tracks onto my phone, everything is ok so far. Now, this is what is niggling me and I don.t know how to resolve it. This is my problem: 
    Have downloaded for example: Queen – Bohemium Rhapsody from a compilation album as well as a few complete Queen Album CDs into the iTunes library and then put them into playlists,
    When I go onto my phone and select Queen on the MUSIC app using Songs tab at the bottom of the screen it will display all Queen songs and their resective Alum pics, that is all those not in a complilation album, .
    If I know the song title I can select the songs tab and find the song that way,
    I’ve tried fiddling with the settings in the iTunes app by going to ‘get info’ tab and trying to sort the problem out that way but am not having much luck.What I want the phone to do is show, for example all Queens songs including those in compilation albums. Can this be done, would be grateful for any ideas on how it can be done, that is if ic can be done, any ideas
    Thanks for your help

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • HT1369 hey, when I connect either my ipod or ipad to itunes I get the promt ' i tunes was unable to load data class information from sync services. Reconnect or try again later'. Can anyone help me with syncing my devices?? Thanks in advance

    Hey, when I connect either my ipod or ipad to itunes I get the prompt 'itunes was unable to load data class information from sync services. Reconnect or try again later. Can anyone help me with syncing my devices?? Thanks in advance

    I am having the same issue, anyone else ?

  • "It is formatted incorrectly, or is not a format that iBooks can open". Can anyone help me with this message of a book that I purchased on iBooks, read, highlighted in the book and now I can't open it anymore. Please help!!!

    "It is formatted incorrectly, or is not a format that iBooks can open". Can anyone help me with this message of a book that I purchased on iBooks, read, highlighted in the book and now I can't open it anymore. Please help!!!

    Mine does the same thing occasionally, is your phone jailbroken? Sometimes it will work if you delete the book and reinstall it or put your phone into airplane mode then turn it back off.

  • I can't find the 2G, 3G and LTE options after updating to iOS8.1, can anyone help me with this? I'm using iPhone5s

    I can't find the 2G, 3G and LTE options after updating to iOS8.1, can anyone help me with this? I'm using iPhone5s

    I have check on my service provider about the correct APN settings, but unfortunately doesnt work still..

  • I need to reinstall my operating system for 10.5 after seeing a file folder and question mark flashing on my start up screen. Can anyone help me with this?

    I need to reinstall my operating system for 10.5 after seeing a file folder and question mark flashing on my start up screen. Can anyone help me with this?

    Hello,
    That means it can find the Hard Drive, or can't find the things needed for booting.
    See if DU even sees it.
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)

  • HT1365 Hi can anyone help with this issue regarding my wireless magic mouse? When im on google chrome and scrolling down the page i always have youtube running in the background but the audio cuts/spits/pops can anyone help me with this?

    Hi can anyone help with this issue regarding my wireless magic mouse? When im on google chrome and scrolling down the page i always have youtube running in the background but the audio cuts/spits/pops can anyone help me with this?

    The figures you mention only make sense on your intranet.  Are you still using the same wireless router.  The verizon one is somewhat limited as far as max wireless-n performace.  For one thing it only has a 2.4 radio.   I like many people who wanted wireless-n performance before they even added a wireless-n gigabit router, have my own handling my wireless-n network.

  • When my screen saver has been on a while, I have to use the cursor to "rub out" part of the screen saver to see my login section. Can anyone help me with this?

    When my screen saver has been on a while, I have to use the cursor to "rub out" part of the screen saver to see my login section. Can anyone help me with this?

    I don't have a solution for you, but just wanted to let you know I used to have the exact same problem. I resolved it (for the most part....about 90% of the time, anyway) by adjusting the screensaver and power settings to never let the computer go to sleep.

  • HT201210 (The iPhone "Named" cannot be restored at this time because the iPhone software update server could not be contacted or is temporarily unavailable.) can anyone help me with this issue, every time i try to restore it will come up like this error m

    (The iPhone "Named" cannot be restored at this time because the iPhone software update server could not be contacted or is temporarily unavailable.)
    can anyone help me with this issue, every time i try to restore it will come up like this error message.

    Restore the iPhone when connected to iTunes by cable.
    Still the same TS1275?
    Is your iPhone jailbroken?
    Or
    Has your computer ever been used to jailbrake or downgrade (Tinyumbrella) any iPhone?

  • When typing the name of the contact I want to send a text message to, names from my contact list no longer pop up as suggestions. Can anyone help me with this?

    When typing the name of the contact I want to send a text message to, names from my contact list no longer pop up as suggestions. Can anyone help me with this?

        There's always a way to reset the device jmn33! Thanks for keeping us in the loop. To process a full reset/restore on the device please visit http://vz.to/12TLCsR. Please keep us posted once this is completed, thanks!
    MatthewS_VZW
    Follow us on Twitter @VZWSUPPORT

  • My search bar for my library no longer works. Also, the menu bar is no longer visible. Noticed this problem last Saturday. Can anyone help me with this?

    My search bar for my iTunes library no longer works. Also, the menu bar is no longer visible. Noticed this problem last Saturday. This might be an issue with my desktop, and not iTunes itself Can anyone help me with this?

    Press Ctrl-B to toggle the menu bar on and off.
    When you say that the "search bar for my iTunes library no longer works" can you be more specific?  The operation of the search function has changed in iTunes 12, essentially having two very distinct modes:
    when Search Entire Library is checked, entering a search string will generate a dropdown of all matching items within your whole library, from which multiple operations are available via context menus
    when Search Entire Library is unchecked, entering a search string creates a filtered view of whatever your current focus is (e.g., if you're looking at a playlist the filter applies only to items in that playlist) with none of the dropdown options as in the first case

Maybe you are looking for