Detecting button press during scroll

Help and questions on programming the codebug
Post Reply
Posts: 1
Joined: Fri Sep 04, 2015 1:55 pm

Detecting button press during scroll

Post by aoakley »

I'd like to create a program which scrolls some text (easy) and then, while the text is scrolling, if it detects a button press (harder), abandon the scrolling text and perform some other subroutine (I have in mind a very simple Tetris-like game where you line up falling dots to make solid lines).

Is there a way to detect button presses and farm out to a subroutine during text scrolling?

My workaround is to scroll the text 1 character at a time, and try to detect presses between characters, but this is ungainly, especially as there appears to be no string handling so I'd need as many blocks as I have characters (I don't think I can store the string and iteratre through it).

One way might be having multiple Start blocks. Scratch supports this, for example. Is that possible in Codebug?
Posts: 67
Joined: Sat Aug 15, 2015 1:41 pm

Re: Detecting button press during scroll

Post by pigraham »

I think the only way is to do your own scroll string sprite and include your polling in that loop.

There seems to be no way to call subroutines, so you are heading for nesting hell.

See this example ... -and-poll/

Sadly there is no event callback mechanism. When the bug is busy scrolling text it can't so anything about button presses. That would be nice.
Post Reply