Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

'sprite' dragging (made progress but have new problems)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2008, 05:50 PM
Junior Member
 
Join Date: Feb 2008
Posts: 17
Default 'sprite' dragging (made progress but have new problems)

I was wondering whether someone who is better at basic4ppc than I could take a look at my code and tell me where I'm going wrong!

The attached project works on my desktop but has the following problems on my PPC:

a) the subroutine:

Sub hk_HardKeyPressed

Select hk.KeyPressed
Case hk.KeyEnter:
AppClose
End Select

End Sub

does not function as expected (i.e. to end the program). I am sure this is something very simple but I have the exact same subroutine in another program and it works fine!

b) The screen does not display properly on my PPC. This is probably due to the method I am using, which as is follows
1. in App_Start, I use formMain.DrawImage to draw a permanent background image onto the backlayer of formMain
2. then, every timer tick, I erase the entire forelayer of formMain and use formMain.fDrawImage to draw the appropriate icons onto it

The reason I want to draw the screen this way (rather than use Sprites) is so that the icons can be dragged around smoothly using the touch screen (currently they are constrained so they can only be dragged 2 hexes straight up). I realise that erasing and then re-drawing the entire forelayer every time is inefficient but that is something I can look at later.

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 03-05-2008, 06:44 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I'm still looking through your code, however the reason for the hardkeys not working is because you've overlooked creating a new instance in app_start.
Just add hk.new1("form1",true,true,true) and you'll be up and running again.
Will get back to you about the display problem when I suss out what happening.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #3 (permalink)  
Old 03-05-2008, 09:00 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Attached is a modified code that will hopefully get you moving forward again.
It's not complete as I somewhat struggled to understand exaclty what was happening with the maths.
Basically I'm approaching the problem by storing the last x and y of the icon so that when it moves the previous position can be erased.
Some of your code is duplicated such as creating a new instance of drawer etc, you only need do this the once.
Hope this is enough to help you see a way forward.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 03-06-2008, 10:39 AM
Junior Member
 
Join Date: Feb 2008
Posts: 17
Default

Thank you very much for having a look at my code!
It seems that the display problems on the PPC were caused by refreshing the entire form at every timer tick which was obviously more than it could handle. I will continue with the method you have implemented - it looks like a good solution. It is certainly more efficient and much less flickery.

There still seems to be an issue with the display on the PPC though - transparency. It works fine on the desktop, but what should be transparent shows up black on the PPC. Something to worry about later though perhaps. Thanks again for your help.
Reply With Quote
  #5 (permalink)  
Old 03-06-2008, 11:29 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Yes I saw the problem last night but thought that there must be a way around it.
Anyway, I seem to recall this issue being raised before - and here it is.... http://www.basic4ppc.com/forum/showt...hlight=overlap
Hopefully this will solve your problem although it looks like it is a little convoluted.

Basically I think that the idea is to draw the image and store its position. Then redraw in a new position, repaint the background using the stored (last position values) and store the new position again etc.

I noticed that you were redrawing all three icons each time. Ideally you only want to redraw the items that have changed. This will significantly improve the speed of operation as only small changes will be being made each cycle.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #6 (permalink)  
Old 03-06-2008, 12:51 PM
Junior Member
 
Join Date: Feb 2008
Posts: 17
Default

Success!

Thanks for that forum link, it was very helpful. It seems the key is not to use the forelayer at all but draw entirely on the backlayer.
I implemented another bitmap as a buffer (as you suggested) to keep track of what has to be redrawn under the icon that is moving. This works great.
The code needs a lot of cleaning up, and there are still some issues that need to be addressed (such as: still doesn't work properly on PPC), but I am well on my way now.

I have attached my code in case you want to see what I have done.
Attached Files
File Type: sbp space_mod2.sbp (9.0 KB, 15 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Low-level FTP upload with progress brathbone Open Source Projects 5 09-26-2009 06:59 AM
Two new Twitter apps. made with Basic4ppc bluedude Share Your Creations 1 05-06-2008 01:12 PM
Sprite problems willisgt Questions (Windows Mobile) 2 02-28-2008 05:30 PM
Progress bar on FTP download willisgt Questions (Windows Mobile) 16 01-28-2008 04:22 PM
Vertical Progress bar davelew1s Questions (Windows Mobile) 2 08-23-2007 06:09 PM


All times are GMT. The time now is 08:55 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0