<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Create a scrollable Map with Cells &#8211; Part II</title>
	<atom:link href="http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html</link>
	<description>Rapid android development from Berlin</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:50:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Amanzzz</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1687</link>
		<dc:creator>Amanzzz</dc:creator>
		<pubDate>Fri, 18 Feb 2011 21:19:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1687</guid>
		<description>Hello,
  If u try using big image instead of small images(grass) ur applications gets un-installed  b&#039;cause it uses lot of memory.. the device stops all the services and in the end uninstalls the application...what may be the problem and how can one solve that...I guess their is lot of drawing going on...in the thread which must be avoided...please suggest me the solution....</description>
		<content:encoded><![CDATA[<p>Hello,<br />
  If u try using big image instead of small images(grass) ur applications gets un-installed  b&#8217;cause it uses lot of memory.. the device stops all the services and in the end uninstalls the application&#8230;what may be the problem and how can one solve that&#8230;I guess their is lot of drawing going on&#8230;in the thread which must be avoided&#8230;please suggest me the solution&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1429</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 04 Nov 2010 08:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1429</guid>
		<description>There is a third part: http://www.droidnova.com/create-a-scrollable-map-with-cells-part-iii,737.html</description>
		<content:encoded><![CDATA[<p>There is a third part: <a href="http://www.droidnova.com/create-a-scrollable-map-with-cells-part-iii,737.html" rel="nofollow">http://www.droidnova.com/create-a-scrollable-map-with-cells-part-iii,737.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robbe</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1427</link>
		<dc:creator>Robbe</dc:creator>
		<pubDate>Thu, 04 Nov 2010 04:23:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1427</guid>
		<description>@Dave I&#039;d be interested in seeing what you have come up with..

/r</description>
		<content:encoded><![CDATA[<p>@Dave I&#8217;d be interested in seeing what you have come up with..</p>
<p>/r</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1394</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Wed, 06 Oct 2010 18:21:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1394</guid>
		<description>I completely redid what you had posted and made it worlds more efficient including the fling scroll with little to no flicker whatsoever.  I&#039;ll try to post the code somewhere if people are interested.  But these two lines REALLY baffled me:

        mXScrollOffset = (int) (((mXOffset / (float) mCellSize) - (mXOffset / mCellSize)) * mCellSize);
        mYScrollOffset = (int) (((mYOffset / (float) mCellSize) - (mYOffset / mCellSize)) * mCellSize);

It seems to me that what you REALLY are looking for is:
    mXScrollOffset = mXOffset % mCellSize;
    mYScrollOffset = mYOffset % mCellSize;

like all other high-performance style enhancements for games, avoiding floating point math is usually a good idea.

In addition, I added a constructor that allows the CellMap view to be used in the XML file so that you don&#039;t have to worry about creating it in the activity.  I generally try to stay away from creating views in my code &quot;when ever possible&quot; to give maximum flexibility to the UI by just changing the XML.  This allowed me to put the map anywhere on the screen, and resize it to any size desired.

Further, I&#039;m not sure why you created the map using that HashMap, especially since you already were hard coding the height and width of the map.  Since you already know the size of the map, it really didn&#039;t make sense; not only from a memory usage point of view but a speed point of view as well.  I actually created an array of bitmaps that were required by the map, and then just created a two-dimensional array of indexes into that array of bitmaps.  I used a two-dimensional array of shorts to save space so even on a 300x300 map, it would only take a maximum of 180K of memory (plus a little overhead for the bitmap array, but that&#039;s inconsequential).  I also simplified a lot of the other code, added a ton of comments, added a very simple hook to manage &quot;Pinch and Zoom&quot; based on the size of each icon and being able to change that dynamically.  If people are interested in trying it out, let me know by posting here.</description>
		<content:encoded><![CDATA[<p>I completely redid what you had posted and made it worlds more efficient including the fling scroll with little to no flicker whatsoever.  I&#8217;ll try to post the code somewhere if people are interested.  But these two lines REALLY baffled me:</p>
<p>        mXScrollOffset = (int) (((mXOffset / (float) mCellSize) &#8211; (mXOffset / mCellSize)) * mCellSize);<br />
        mYScrollOffset = (int) (((mYOffset / (float) mCellSize) &#8211; (mYOffset / mCellSize)) * mCellSize);</p>
<p>It seems to me that what you REALLY are looking for is:<br />
    mXScrollOffset = mXOffset % mCellSize;<br />
    mYScrollOffset = mYOffset % mCellSize;</p>
<p>like all other high-performance style enhancements for games, avoiding floating point math is usually a good idea.</p>
<p>In addition, I added a constructor that allows the CellMap view to be used in the XML file so that you don&#8217;t have to worry about creating it in the activity.  I generally try to stay away from creating views in my code &#8220;when ever possible&#8221; to give maximum flexibility to the UI by just changing the XML.  This allowed me to put the map anywhere on the screen, and resize it to any size desired.</p>
<p>Further, I&#8217;m not sure why you created the map using that HashMap, especially since you already were hard coding the height and width of the map.  Since you already know the size of the map, it really didn&#8217;t make sense; not only from a memory usage point of view but a speed point of view as well.  I actually created an array of bitmaps that were required by the map, and then just created a two-dimensional array of indexes into that array of bitmaps.  I used a two-dimensional array of shorts to save space so even on a 300&#215;300 map, it would only take a maximum of 180K of memory (plus a little overhead for the bitmap array, but that&#8217;s inconsequential).  I also simplified a lot of the other code, added a ton of comments, added a very simple hook to manage &#8220;Pinch and Zoom&#8221; based on the size of each icon and being able to change that dynamically.  If people are interested in trying it out, let me know by posting here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1297</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Tue, 10 Aug 2010 16:40:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1297</guid>
		<description>Thank you for these wonderful tutorials. I&#039;m a self-taught novice programmer who has been studying android since the 0.9 SDK. I haven&#039;t been able to wrap my head around 2D graphics programming until I came across your tutorials. Your 2D tutorials and these map tutorials are my graphics savior and for that, I thank you once more.</description>
		<content:encoded><![CDATA[<p>Thank you for these wonderful tutorials. I&#8217;m a self-taught novice programmer who has been studying android since the 0.9 SDK. I haven&#8217;t been able to wrap my head around 2D graphics programming until I came across your tutorials. Your 2D tutorials and these map tutorials are my graphics savior and for that, I thank you once more.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1225</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sat, 10 Jul 2010 17:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1225</guid>
		<description>Martin,
First off, thanks for all of your great tutorials.  I am a java app designer for a company in Asheville North Carolina, but, this is my first experience using the Android SDK.   Your tutorials have been more help than the android dev guide....
A question, you said if you character can walk free, you would prefer another way to draw the map.  Can you tell me the way?  Maybe some pseudo code, or a brief rundown?

Thanks again,
Andrew C.</description>
		<content:encoded><![CDATA[<p>Martin,<br />
First off, thanks for all of your great tutorials.  I am a java app designer for a company in Asheville North Carolina, but, this is my first experience using the Android SDK.   Your tutorials have been more help than the android dev guide&#8230;.<br />
A question, you said if you character can walk free, you would prefer another way to draw the map.  Can you tell me the way?  Maybe some pseudo code, or a brief rundown?</p>
<p>Thanks again,<br />
Andrew C.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sean</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1172</link>
		<dc:creator>sean</dc:creator>
		<pubDate>Tue, 22 Jun 2010 00:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1172</guid>
		<description>I get a NullPointerException when I touch the screen on my Motorolla Droid.  The example above works fine in the emulator (I can pick a cell fine and the Toast shows the cell that was selected).  The error is that the Cell is null after it comes back from the touchEvent.  Anyone else experiencing this issue?  I even downloaded the sample code and ran that, same issue.  Little help please.  Thanks, Sean</description>
		<content:encoded><![CDATA[<p>I get a NullPointerException when I touch the screen on my Motorolla Droid.  The example above works fine in the emulator (I can pick a cell fine and the Toast shows the cell that was selected).  The error is that the Cell is null after it comes back from the touchEvent.  Anyone else experiencing this issue?  I even downloaded the sample code and ran that, same issue.  Little help please.  Thanks, Sean</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1153</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Mon, 14 Jun 2010 16:38:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1153</guid>
		<description>When your character movement is cell based, than you should use this technique, if your character can walk free, than I would prefer another way to draw the map.</description>
		<content:encoded><![CDATA[<p>When your character movement is cell based, than you should use this technique, if your character can walk free, than I would prefer another way to draw the map.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1152</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Mon, 14 Jun 2010 16:30:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1152</guid>
		<description>Martin-for an RPG game where you have a character moving around on a &quot;map&quot;, would you use a grid with the tiles like you suggested and have different squares be monsters, buildings, caves etc? Thanks for all the great tutorials.  -Sean</description>
		<content:encoded><![CDATA[<p>Martin-for an RPG game where you have a character moving around on a &#8220;map&#8221;, would you use a grid with the tiles like you suggested and have different squares be monsters, buildings, caves etc? Thanks for all the great tutorials.  -Sean</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.droidnova.com/create-a-scrollable-map-with-cells-part-ii,678.html/comment-page-1#comment-1129</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Tue, 01 Jun 2010 15:02:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.droidnova.com/?p=678#comment-1129</guid>
		<description>Hm... I work with a modified version of that ScrollMap every day the last couple of weeks and have never seen this issue on my Nexus One. Can you check the coordinates of your TouchEvent with LogCat and post a &quot;typical&quot; tap you made?</description>
		<content:encoded><![CDATA[<p>Hm&#8230; I work with a modified version of that ScrollMap every day the last couple of weeks and have never seen this issue on my Nexus One. Can you check the coordinates of your TouchEvent with LogCat and post a &#8220;typical&#8221; tap you made?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

