AngelWire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2011
02:01 PM
Re: Display an image
Thanks RokuMarkn, that helps a lot! One last question(I hope), how do I check if a button on the remote is pressed? I've looked through the examples and documentation but I can't get anything to work.

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2011
03:58 PM
Re: Display an image
See page 58 of the Brightscript 3.0 Reference. The roUniversalControlEvent object that you receive has a GetInt method that returns the id of the key pressed.
--Mark
--Mark
AngelWire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2011
05:20 PM
Re: Display an image
I finally got it working, but how would I check if the button is still being held instead of just pressed?
This is what I have so far but it's not working:
This is what I have so far but it's not working:
while true
x = x+xto
y = y+yto
scr.setalphaenable(true)
BackGround(scr)
scr.drawobject(x, y, logo)
scr.swapbuffers()
msg = wait(0, port)
if type(msg) = "roUniversalControlEvent" then
if msg.getint()= 2
yto = -5
else if msg.getint()= 3
yto = 5
else if msg.getint()= 4
xto = -5
else if msg.getint()= 5
xto = 5
else if msg.getint()= 102
yto = 0
else if msg.getint()= 103
yto = 0
else if msg.getint()= 104
xto = 0
else if msg.getint()= 105
xto = 0
end if
end if
end while
AngelWire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
02:08 PM
Re: Display an image
"AngelWire" wrote:
I finally got it working, but how would I check if the button is still being held instead of just pressed?
Alright, I got that fixed, but now I figured out that the background is taking a ton of memory and causing the game to run super slow(from 59.9 fps to 8 ). Any suggestions?
YungBlood
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
02:11 PM
Re: Display an image
When you press a button, you will get 2 events. First, you will get the press event (i.e. 2), then you release the button, you get the release event (i.e. 102). That allows a lot of flexibility. If you want to enforce only receiving "presses", then just set a release var when you get the press event, and clear it when you get the release event. (If you're not sure what I mean, I can give you a piece of code)
Also, I don't know if it makes a difference to roku, but I recommend making a small change to your code. Instead of using:
Use this instead:
Also, I don't know if it makes a difference to roku, but I recommend making a small change to your code. Instead of using:
if msg.getint() = 2 then
...
else if msg.getint() = 3 then
...
Use this instead:
key = msg.getint()
if key = 2 then
....
else if key = 3 then
...
YungBlood
Bringing more fun to Roku!
Bringing more fun to Roku!
YungBlood
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
02:17 PM
Re: Display an image
"AngelWire" wrote:
Alright, I got that fixed, but now I figured out that the background is taking a ton of memory and causing the game to run super slow. Any suggestions?
Good question. I'm noticing that a bit on the HD version of my memory match game. I don't have the solution yet, but I am looking into speed improvements. I'll keep you posted with that I find.
YungBlood
Bringing more fun to Roku!
Bringing more fun to Roku!
AngelWire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
02:36 PM
Re: Display an image
Thanks YungBlood. The problem was msg = wait(0, port), I changed it to msg = port.getmessage() and it works fine.
EDIT:
I fixed the speed issue, the problem was bg = CreateObject("roBitmap", "pkg:/images/grass.png") was in the while loop. I moved it and now it's running at 60 fps.
EDIT:
I fixed the speed issue, the problem was bg = CreateObject("roBitmap", "pkg:/images/grass.png") was in the while loop. I moved it and now it's running at 60 fps.
YungBlood
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
06:41 PM
Re: Display an image
Good to know you got it running better. I don't have the create object in my loop, but my code runs a bit slow in HD. Could simply be the number of objects I'm drawing...
YungBlood
Bringing more fun to Roku!
Bringing more fun to Roku!
- « Previous
-
- 1
- 2
- Next »