How to do "when pressed for milliseconds"

nindroidgames
helpwithcodee
secondtutorialtoday
ripthelmbs

#1

NOTE: This may not be perfect. If I change it, let me know if I should tag you.

So, I really only have screenshots.


Link:

This was inspired by @Gobli09 not knowing how to do this. I came up with it in five minutes, thus it being possibly flawed.


#2

Thanks a lot! :smile:


#3

No problem! I really enjoy helping people.


#4

I'll help improve it! Mind if I make my own prototype? ^^

Tag me when you change it, please. :)


#5

Nope. And sure, I'll tag you. :smiley:


#6

Cool! I'll watch this topic as well. ^^


#7

Wow, That's really cool!
I'm not sure I have anything to use it for, but I totally have to bookmark this.


#8

Wut.... smarty! :stuck_out_tongue: I'm bookmarking that..


#9

It's obvious. Really, it took more like 2 5 minutes.


#10

Yeah, 2 mins. Show off! :stuck_out_tongue: lol, jk. Now I wanna be homeschooled even more.


#11

I'm going to make a customizable button that you can change the press-time of. ^^


#12

Cool! You should post it here!


#13

Homeschool has nothing to do with it.


#14

Actually, it does. There's some study that shows that homeschooled people are smarter and better-tuned to their jobs that people that go to a school.


#15

I don't believe that. However, apparently because I want real butter, I'm homeschooled. XD


#16

So I just figured out Hopscotch's normal FPS: 60. Sorry I'm taking so long to make this; there's a TV playing in this room and a little brother annoying me. XD

It'll be done within 10 minutes!


#17

Cool! I was going to start making a custom block with only one or 2 variables, cuz I use too many. That's one of the reasons my draw pad might not have worked.


Hehe, I get the annoyance, I have a lil bro too. As for the TV, I don't have/want one.


#18

I think it's awesome you were thinking about a workaround! (Even if it hadn't worked out!)


Do you happen to have a general topic, – I really wish I could do unschooling :cry: Actually, never mind


#19

He has a GT, I'll invite you there, if you want..
But he is at mine most of the time. Idk why.


#20

I've got it!

Okay, so there's a bit of code meta you'll need to know first to understand how I made this project.

Every second, a program/Hopscotch project processes a certain number of repetitions, known as frames, in a real-time second: this is called FPS, or frames per second. After a bit of experimenting, I figured out that the average FPS in Hopscotch is 60 FPS.

Since there are 60 frames in a second, that means if you increase a variable 60 times, 1 real life second will pass by!


So basically, I made "if pressed" and "if not pressed" conditions. When it's pressed, it'll increase the counter, while if it's not, it'll reset back to 0.

When you press the button, it'll count to 60 (a full second), then it'll change the colors! Let go, and it'll reset. ^^

Hope this helps!! When you want to make it wait a second, just make a counter variable count to 60! Half a second is 30, a fourth of a second is 15, etcetera. :D


New idea for a block!(tell me if I should put it in this category)
How do I make a stopwatch?