If your game is offering a web-based architecture (for example, a 2D version of the game) you can use the Web SDK to implement the ads in your game.
Installing the Web SDK is as simple as running the following command in your project's directory:
npm install @heyvr/sdk-ad-web
Then, simply import the installed package into your project:
import * as heyVRAds from "@heyvr/sdk-ad-web";
Not using NPM for dependency management?
Simply download the SDK file from here and include it in your build viascript
tag in yourindex.html
.
Once you're done with the installation, it's time to render the ads in your game.
Loading the SDK will register a new custom component named heyvr-ad
. You can use this custom component to render ads in your game. Let's start by placing a video ad in the game:
<html>
<head>...</head>
<body>
<h1>heyVR Video AD</h1>
<heyvr-ad adUnit="my_org-sample-ad-unit" width="500px"></heyvr-ad>
</body>
</html>
That's it! If you load the game in the browser, you should start getting ads.
The ad web component accepts 2 additional parameters in addition to the common params:
width
- Width of the ad, in pixels. e.g. "500px"height
- Height of the ad, in pixels. e.g. "200px"Please note that only one of these values will be effective, as the system will adjust the aspect ratio automatically.
Not sure about the common configuration params? Checkout this section regarding shared SDK parameters.