<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Making Buttons</title>
		<link>http://www.allegro.cc/forums/view/607623</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 17 Jun 2011 09:46:03 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How can I find a tutorial for making buttons and setting events happening when clicked</p><p>EDIT: Also another problem with my compiler, thanks if you can tell why;</p><p>When I compile using Release option in VS, I get;</p><p>1&gt;------ Build started: Project: Allegro, Configuration: Release Win32 ------<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_draw_bitmap_region<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_flip_display<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_map_rgb<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_destroy_event_queue<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_clear_to_color<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_register_event_source<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_wait_for_event<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_destroy_timer<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_start_timer<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_get_keyboard_event_source<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_draw_bitmap<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_create_event_queue<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_create_display<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_create_timer<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_load_bitmap<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_install_system<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_get_display_event_source<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_get_timer_event_source<br />1&gt;main.obj : error LNK2001: unresolved external symbol _al_init_image_addon<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_destroy_display<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_set_new_bitmap_flags<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_install_keyboard<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_path_cstr<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_is_event_queue_empty<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_destroy_bitmap<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_destroy_path<br />1&gt;main.obj : error LNK2001: unresolved external symbol __imp__al_get_standard_path<br />1&gt;C:\Documents and Settings\Quarynn\my documents\visual studio 2010\Projects\Allegro\Release\Allegro.exe : fatal error LNK1120: 27 unresolved externals<br />========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</p><p>Thought I don&#39;t get any with Debug option, why?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Zephelin)</author>
		<pubDate>Thu, 16 Jun 2011 15:43:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I used this logic to code all of my buttons (the actual sprites were created in GIMP/Powerpoint):</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>  <span class="c">//x represents the x coordinate of the bitmap</span>
<span class="number">  2</span>  <span class="c">//y represents the y coordinate of the bitmap</span>
<span class="number">  3</span>  <span class="c">//state is of type ALLEGRO_MOUSE_STATE</span>
<span class="number">  4</span>  <span class="c">//mouse_hovering and left_down are bools</span>
<span class="number">  5</span>  <span class="c">//setDrawFrame() is a function I wrote to switch which bitmap is being drawn</span>
<span class="number">  6</span>  <span class="c">//This code goes inside the update function of your button object</span>
<span class="number">  7</span>
<span class="number">  8</span>  <span class="c">//updates state, which is a struct that holds mouse information such as its coordinates on the screen</span>
<span class="number">  9</span>  <a href="http://www.allegro.cc/manual/al_get_mouse_state"><span class="a">al_get_mouse_state</span></a><span class="k2">(</span><span class="k3">&amp;</span>state<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>  
<span class="number"> 11</span>
<span class="number"> 12</span>  <span class="c">//Checks if mouse is hovering over the sprite.</span>
<span class="number"> 13</span>  <span class="c">//if so, it will start drawing a different sprite (kind of like when you hover your mouse over any of your browser buttons</span>
<span class="number"> 14</span>  <span class="k1">if</span> <span class="k2">(</span>state.x <span class="k3">&lt;</span> <span class="k2">(</span>x<span class="k3">+</span><span class="n">30</span><span class="k2">)</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> state.x <span class="k3">&gt;</span> x <span class="k3">&amp;</span><span class="k3">&amp;</span> state.y <span class="k3">&lt;</span> <span class="k2">(</span>y<span class="k3">+</span><span class="n">30</span><span class="k2">)</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> state.y <span class="k3">&gt;</span> y<span class="k2">)</span>
<span class="number"> 15</span>  <span class="k2">{</span>
<span class="number"> 16</span>    setDrawFrame<span class="k2">(</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>    mouse_hovering <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 18</span>  <span class="k2">}</span>
<span class="number"> 19</span>  <span class="k1">else</span>
<span class="number"> 20</span>  <span class="k2">{</span>
<span class="number"> 21</span>    setDrawFrame<span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>    mouse_hovering <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 23</span>  <span class="k2">}</span>
<span class="number"> 24</span>
<span class="number"> 25</span>  <span class="c">//If the left mouse button is being pressed and the mouse is hovering over the button, set a flag;</span>
<span class="number"> 26</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k2">(</span>state.buttons <span class="k3">&amp;</span> <span class="n">1</span><span class="k2">)</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> mouse_hovering<span class="k2">)</span>
<span class="number"> 27</span>  <span class="k2">{</span>
<span class="number"> 28</span>    <span class="c">//you could also set the sprite to yet another frame here, one of the button being depressed.</span>
<span class="number"> 29</span>    left_down <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span> 
<span class="number"> 30</span>  <span class="k2">}</span>
<span class="number"> 31</span>
<span class="number"> 32</span>  <span class="c">//If the flag is on and the mouse button is no longer being clicked, you know the user has released the mouse button</span>
<span class="number"> 33</span>  <span class="k1">if</span> <span class="k2">(</span>left_down <span class="k3">&amp;</span><span class="k3">&amp;</span> <span class="k3">!</span><a href="http://www.allegro.cc/manual/al_mouse_button_down"><span class="a">al_mouse_button_down</span></a><span class="k2">(</span><span class="k3">&amp;</span>state, <span class="n">1</span><span class="k2">)</span><span class="k2">)</span>
<span class="number"> 34</span>  <span class="k2">{</span>
<span class="number"> 35</span>    <span class="c">//don't forget to switch the sprite back to the non-depressed version here.</span>
<span class="number"> 36</span>    left_down <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span> <span class="c">//don't forget to reset the flag</span>
<span class="number"> 37</span>
<span class="number"> 38</span>
<span class="number"> 39</span>    <span class="c">//here goes whatever code you wanted to execute when the button was pressed//</span>
<span class="number"> 40</span>  <span class="k2">}</span>
</div></div><p>

As for your other problem, I think it&#39;s good practice to code a little, then test, then code a little, then test. Using this approach, I never have to deal with more than 1 or 2 errors at a time, and it&#39;s really easy to tell where the error is coming from when it worked 2 seconds ago, you coded a little, and now it&#39;s broken.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPGillespie)</author>
		<pubDate>Thu, 16 Jun 2011 16:15:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What&#39;s the identifier of state?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Zephelin)</author>
		<pubDate>Thu, 16 Jun 2011 16:37:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607623/921651#target">RPGillespie</a> said:</div><div class="quote"><p> //state is of type ALLEGRO_MOUSE_STATE</p></div></div><p>I put it in the comments at the top
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPGillespie)</author>
		<pubDate>Thu, 16 Jun 2011 16:57:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The errors in &#39;release&#39; mode are saying that certain allegro functions are not being found in your final problem. <i>unresolved external symbol</i> means a function was declared and used, but not <i>defined</i>.</p><p>To fix the problem, you need to link to the appropriate libraries which contain the function definitions. The reason it is happening to you in release mode and not debug mode is that you are using different versions of the allegro library. Probably the static version for release and the dynamically linked version for debug.</p><p>Although you are using MSVC, you&#39;ll probably find what you need to know <a href="http://www.cerebrospain.com/allegro_en/conf_cb_static_en.php">here</a>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Karadoc ~~)</author>
		<pubDate>Thu, 16 Jun 2011 17:17:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>1&gt;------ Build started: Project: Allegro, Configuration: Debug Win32 ------<br />1&gt;  main.cpp<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(6): warning C4273: &#39;al_init_image_addon&#39; : inconsistent dll linkage<br />1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\allegro5\allegro_image.h(32) : see previous definition of &#39;al_init_image_addon&#39;<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(153): error C2664: &#39;al_get_mouse_state&#39; : cannot convert parameter 1 from &#39;ALLEGRO_MOUSE_STATE **&#39; to &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(157): error C2228: left of &#39;.x&#39; must have class/struct/union<br />1&gt;          type is &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          did you intend to use &#39;-&gt;&#39; instead?<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(157): error C2228: left of &#39;.x&#39; must have class/struct/union<br />1&gt;          type is &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          did you intend to use &#39;-&gt;&#39; instead?<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(157): error C2228: left of &#39;.y&#39; must have class/struct/union<br />1&gt;          type is &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          did you intend to use &#39;-&gt;&#39; instead?<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(157): error C2228: left of &#39;.y&#39; must have class/struct/union<br />1&gt;          type is &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          did you intend to use &#39;-&gt;&#39; instead?<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(167): error C2228: left of &#39;.buttons&#39; must have class/struct/union<br />1&gt;          type is &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          did you intend to use &#39;-&gt;&#39; instead?<br />1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(173): error C2664: &#39;al_mouse_button_down&#39; : cannot convert parameter 1 from &#39;ALLEGRO_MOUSE_STATE **&#39; to &#39;const ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast<br />========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Zephelin)</author>
		<pubDate>Thu, 16 Jun 2011 17:28:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607623/921658#target">Karadoc ~~</a> said:</div><div class="quote"><p> Although you are using MSVC, you&#39;ll probably find what you need to know here [www.cerebrospain.com].</p></div></div><p>Well, actually I put the tutorial there when I didn&#39;t know that there was a wiki about Allegro, well, to be honest I did know that there was a wiki, but I didn&#39;t know how to use it, and was a complete disaster, now still being a disaster but not complete <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />... Anyway the same tutorial is <a href="http://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_10.05_and_Allegro_5">here</a> and has being improved by the own Edgar Reynaldo, so it&#39;s approved.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Thu, 16 Jun 2011 22:57:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607623/921659#target">Zephelin</a> said:</div><div class="quote"><p>
1&gt;c:\documents and settings\quarynn\my documents\visual studio 2010\projects\allegro\allegro\main.cpp(6): warning C4273: &#39;al_init_image_addon&#39; : inconsistent dll linkage</p><p>1&gt;c:\program files\microsoft visual studio 10.0\vc\include\allegro5\allegro_image.h(32) : see previous definition of &#39;al_init_image_addon&#39;
</p></div></div><p>
It sounds like you&#39;re including two different definitions of al_init_image_addon, but A5 should be using include guards so I don&#39;t know how that is possible.</p><div class="quote_container"><div class="title">Zephelin said:</div><div class="quote"><p>
 &#39;al_get_mouse_state&#39; : cannot convert parameter 1 from &#39;ALLEGRO_MOUSE_STATE **&#39; to &#39;ALLEGRO_MOUSE_STATE *&#39;
</p></div></div><p>
It says exactly what it means - you are passing the address of an ALLEGRO_MOUSE_STATE* when it expects an ALLEGRO_MOUSE_STATE*.</p><div class="quote_container"><div class="title">Zephelin said:</div><div class="quote"><p>
left of &#39;.x&#39; must have class/struct/union<br />1&gt;type is &#39;ALLEGRO_MOUSE_STATE *&#39;<br />1&gt;did you intend to use &#39;-&gt;&#39; instead?
</p></div></div><p>
You&#39;re trying to use &#39;.&#39; to access a pointer. You have to use &#39;-&gt;&#39; to access member variables through a pointer.</p><p>After you fix these errors, if you still have errors, post your full code and the errors you get with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 17 Jun 2011 09:46:03 +0000</pubDate>
	</item>
</rss>
