Using AdDuplex in a XNA - Silverlight WP7 hybrid application

Provably most of you know AdDuplex to cross-promote WP7 apps and games. That ad engine provides two SDK's, one for XNA games and another for Silverlight apps.

I have a SL-XNA hybrid game, and I can't find the way to make the ads work in such environment. I've been able to render the ad using a Silverlight UIElementRenderer on the XNA graphics environment, but I can't find the way to handle the click on it.

This is how the XAML looks like:

<Grid Name="root" Margin="0,0,0,7000" Width="480" Height="90" Background="Black" >
    <adduplex:AdControl x:Name="adDuplex" xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.AdControl.Silverlight"

I've heard that some people has used adDuplex in such environments. Any idea on how to do it? Thanks.


Without seeing the code behind and full XAML I can't say for sure but the clue is in the Margin="0,0,0,7000". My guess is that you are drawing the AdDuplex control in a different location to where it is actually positioned.

If you are initialising the UIElementRender something like this

    renderer = new UIElementRenderer(adDuplex, 480, 90);

and drawing like this

    spriteBatch.Draw(renderer.Texture, Vector2.Zero, Color.White);

then that would explain the problem. Instead, set the Margin="0" on the AdDuplex control (making sure that it is visible on the page) and initialise your UIElementRenderer using the root element on your page. By default this is a Grid called "root" but you may have changed this to something else.

renderer = new UIElementRenderer(root, 480, 800);

The draw code should be same as above. The AdDuplex control should now draw in the same location as the actual control and tapping on it should launch the web browser.

You might want to tweek this solution if you don't want to draw a 480,800 bitmap each frame but at least it will test if it fixes the problem.

I'm using AdDuplex in my SL-XNA hybrid app "Yaht 3D" with no problems. It sounds like you are doing everything right. Just drop the Silverlight control into your XAML (using your own app id).

        <adduplex:AdControl xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.AdControl.Silverlight"

and use the UIElementRenderer in the code behind inside your OnDraw method

    spriteBatch.Draw(elementRenderer.Texture, Vector2.Zero, Color.White);

The AdDuplex control should handle the clicks for you.

I used this helper class by Nick Gravelin and now it works like a charm:


Need Your Help

Headache getting php and sql server 2005 to run together

php sql-server

Below is the code that i cannot get to work. I know i have established a connection to the database but this returns nothing. What am i doing wrong?