Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Hide\Show Sprite

Author
Message
burrbittyburr
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location:
Posted: 7th Sep 2003 06:55
I'm trying to figure out how to hide and show a sprite with the same key. This isn't the only code I've tried, but it will show you what I mean. Thanks for reading and please help if you can.

Specs[1 GiG Athlon,Geforce Ti4, 128mb]
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Sep 2003 07:17
Well, that should work. I'll assume you mean you want to toggle back and forth.

This should work

This goes outside the loop:


This goes when you want the program to read the button:


"All programmers are playwrites and all computers are lousy actors" -Anon
[img]Visit my site![/img]
burrbittyburr
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location:
Posted: 7th Sep 2003 22:16
It worked but it's a little buggy, because when the shiftkey is hit the sprite flickers for a few seconds before the change. That's the first time I've seen the Case commands so extra thanks for that one.

Specs[1 GiG Athlon,Geforce Ti4, 128mb]
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 7th Sep 2003 22:31
You need to do a bit more work I'm afraid. The reason for the flicker is that when you press your desired key, program is running so fast that key press is detected in multiple passes of loop.

When you press key, store in a variable fact you have pressed key and don't allow another press of key until you have let go of key.

Try following:



The programmer formerly known as sonic
burrbittyburr
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location:
Posted: 10th Sep 2003 02:41
Thanks Spooky!

Specs[1 GiG Athlon,Geforce Ti4, 128mb]

Login to post a reply

Server time is: 2024-03-02 17:47:37
Your offset time is: 2024-03-02 17:47:37