Detecting button press during scroll

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

Detecting button press during scroll

Post by aoakley » Fri Sep 04, 2015 2:01 pm

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?

pigraham
Posts: 65
Joined: Sat Aug 15, 2015 1:41 pm

Re: Detecting button press during scroll

Post by pigraham » Fri Sep 04, 2015 2:16 pm

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

http://www.codebug.co.uk/explore/codebu ... -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