Teil von  SELFPHP
  +++ SELFPHP CronJob-Service :: Jetzt auch als Professional-Version verfügbar! +++

:: Anbieterverzeichnis ::

Globale Branchen

Informieren Sie sich über ausgewählte Unternehmen im Anbieterverzeichnis von SELFPHP  

 

:: SELFPHP Forum ::

Fragen rund um die Themen PHP? In über 120.000 Beiträgen finden Sie sicher die passende Antwort!  

 

:: Newsletter ::

Abonnieren Sie hier den kostenlosen SELFPHP Newsletter!

Vorname: 
Name:
E-Mail:
 
 

:: Qozido ::

Die Bilderverwaltung mit Logbuch für Taucher und Schnorchler.   

 
 
Adding and Applying Behaviors


SELFPHP Produktempfehlung
Microsoft Windows Server 2008
Seite Windows Server 2008
Seite

Microsoft SQL Server 2008
Seite SQL Server 2008
Seite

Microsoft Expression Web 3
Seite Microsoft Expression
Seite


Applying Behaviors to the Objects in Your Game
Now that you have these new behaviors available for use in Blend, its time to apply them to the objects in your game. Applying Behaviors is simply a matter of dragging them from the Asset Library onto the objects which you would like the behavior applied. Once a behavior has been applied to an object, there are default properties that you may modify. In some cases, the default properties of a behavior will be fine, however in many cases you will have to change them. The first behavior you will add is one that forces the paddle to follow the user’s mouse.

  1. First, you will change the layout root of the entire game from a grid to a canvas. Right-click the LayoutRoot element in the Objects and Timeline panel and choose Change Layout Type and select Canvas. A canvas is a fixed width and height container and you want your gaming environment to have a stable environment, it will also help the behaviors function properly.
  2. Open the Asset Library, then click and drag the GameEnvironment behavior onto the LayoutRoot canvas. This behavior is essential to the game as it sets up things like the hit and collision detection.



    Tip: If you are having difficulty seeing the Objects and Timeline panel when the Asset Library is open, you can reduce the size of the Asset Library by clicking and dragging the bottom-right corner.

  3. Now you’ll add the Followmouse behavior to the paddle. Select the Paddle object in the Objects and timeline panel, then click and drag the Followmouse behavior onto the paddle element in the same panel. Note that whenever a behavior is applied to an object (in this case the paddle) the behavior is labeled and indented within the Objects and Timeline panel.
  4. After the FollowMouse behavior is added you now modify the default properties. Within the Properties panel you will see a Mouse Properties section has now been exposed (if you do not see this make sure the FollowMouse behavior is selected in the Objects and Timeline panel). Click the FollowPosition menu and choose the value X. Because the paddle only moves from left to right, you want to make sure it only moves on the X or horizontal axis.




  5. Return to Assets Panel, then drag and drop the collision behavior onto the paddle. In the Collision Properties section, check the Collide with All checkbox.
  6. Now you’ll add a behavior to the ball. Select the ball (or ellipse) object in the Objects and Timeline Panel. Rename the ellipse to Ball if necessary. Drag and drop the Motion behavior onto the ball. This behavior will set the ball in motion once the user clicks on it.
  7. Locate the Motion Properties section and change the direction value to -65 and change the speed value to 10.
  8. Now drag the Collison Behavior onto the ball and in the Change Properties section, click the Action menu and choose Motion_ChangeDirection.




    This collision behavior instructs the ball to change direction when it hits an object. In order to test this, click and drag a honeycomb above and to the right of the ball so that when the ball is activated it immediately runs into the honeycomb.




  9. Rename this honeycomb honeycomb_01. After moving the honeycomb in front of the ball, you also need to make sure the honeycomb is enabled for collision. Click and drag the collision behavior on top of the Honeycomb.
  10. In the Properties Panel, locate the Change Properties section and change the Action to Visibility and then beneath in the Value field, type Collapsed.

    Additionally, in the Collision Properties, click the CollideWithAll checkbox to make sure it is selected. The combination of these properties instructs the honeycomb to disappear when it is hit.
  11. Test your application by pressing F5. Move your mouse to makes sure the paddle follows the movement. Click on the ball to start its motion, if you placed the honeycomb correctly it will be hit immediately and disappear. The ball will bounce off in another direction and disappear because of course there are no walls yet to stop its progress! These will be added in an upcoming module.


Seite 2 von 2 1 2



Downloads

Copyright © 2010
Microsoft Deutschland GmbH
Alle Rechte vorbehalten.

 Microsoft Deutschland GmbH
 




:: Premium-Partner ::

Webhosting/Serverlösungen


Premium-Partner MECO Systemhaus GmbH & Co. KG
Premium-Partner PSW GROUP GmbH & Co. KG
Premium-Partner BPI-Systeme
Premium-Partner Pixel X
Premium-Partner
 

:: SELFPHP Sponsoren ::


DM Solutions
Microsoft Deutschland GmbH
twosteps.net - ...Premium-Webhosting
Sedo - Bei uns wird PHP großgeschrieben
hostfactory.ch - OptimaNet Schweiz AG
ZEND - The PHP Company
Kaspersky Labs
HighText iBusiness
SELFPHP Sponsoren
 

Qozido


© 2001-2013 E-Mail SELFPHP OHG, info@selfphp.deImpressumKontakt