Getting started - Introduction - Installing Defold - The editor - Glossary - Defold for Flash users - Getting help Project setup - Creating a project - Project settings - Libraries Core concepts - Building blocks - Addressing - Message passing - Application lifecycle Assets and resources - Importing assets - Importing 2D graphics - Importing 3D models - Adapting to different screen sizes - Live update - Animation - Atlas - Font - Resource management - Tile source - Texture filtering - Texture profiles Components - Overview - Collection factory - Collection proxy - Collision object - Camera - Factory - Label - Mesh - Model - Particle FX - Sound - Spine animation - Spine model - Sprite - Tilemap Gui - GUI overview - Box nodes - Text nodes - Pie nodes - Spine nodes - ParticleFX nodes - Template nodes - Scripts - Clipping - Layouts Physics - Physics overview - Collision objects - Collision shapes - Collision groups - Collision messages - Resolving collisions - Ray casts - Joints and constraints Game logic - Scripts - Properties - Script properties - Lua in Defold - Input - Modules - Debugging Saving and loading files - Working with files Networking - Overview - HTTP Requests - Socket connections - WebSocket connections - Online services Rendering - Render - Material - Shader - Texture filtering Workflow - Adapting to different screen sizes - Bundling an application - Bob the builder - Hot reloading - Optimizing an application - Profiling - Refactoring - The mobile dev app - Version control - Writing code - Working offline Debugging - Debugging game logic - Debugging native code - Debugging native code on Android - Debugging native code on iOS - Reading game and system logs - Profiling Platforms - Android - iOS - Nintendo Switch - Linux - HTML5 - macOS - Windows Monetization - Ads - In-app purchases - Web Monetization Extensions - Advertising Info - Camera - Facebook - Facebook Instant Games - Firebase Analytics - Google Play Game Services - Google Play Instant - In-app purchases - Inter-app communication - Push notifications - App review and ratings - WebMonetization - WebSocket - Webview Native extensions - Introduction - Details - Defold SDK - Adding auto-complete definition - Best Practices - Debugging - Build Variants - Manifest Merging Editor extensions - Editor scripts
Read this manual in English
网页游戏盈利
Web Monetization 是一种开放的技术手段, 能让浏览网站或者玩网页游戏的用户向作者进行 (超小额度) 付款而且实时到账. 这给网页游戏开发者一条新的生财之道, 同时付款的玩家会获得额外的高端游戏内容.
网页微支付 已被提名为 W3C 标准 . 它基于 Interledger 协议, 一种开放的, 中立的任意货币转账协议, 包括比特币这样的数字货币.
如何工作?
转账要满足以下需求:
玩家必须持有 Web Monetization Provider 账户 - 玩家付款的账户.
开发者必须持有 Web Monetization Wallet 账户 - 开发者收款的账户.
开发者必须在网页上放置 Payment Pointer 其中包含需要付费才能得到的内容 - 支付点用来确定把款项发往哪个钱包.
网页支付账户
玩家必须持有网页支付提供商提供账户以便向游戏开发者付款:
目前 Coil 是唯一的网页支付服务提供商, 以后会越来越多.
网页钱包账户
开发者必须持有网页支付钱包以便接收付款. 已经有许多服务提供商提供网页钱包服务:
支付点
钱包提供商把支付点与钱包对应. 支付点是钱包的收款地址, 它可以被随意公开出去. 详情请见 paymentpointers.org . 支付点就像一个网络连接, 但是是由 $ 开头:
$ilp.uphold.com/QkG86UgXzKq8
支付点要加入到网页 <head>
标签中的 <meta>
标签里:
<meta name= "monetization" content= "$ilp.uphold.com/QkG86UgXzKq8" >
在 Defold 中配置支付点
在 Defold 游戏中使用网页支付功能是个简单的过程. 新建项目和已有项目的配置方法略有不同.
新建项目
如果是新建项目强烈建议你使用 Defold 欢迎屏幕里的网页支付项目模板. 这个模板包含了 网页支付原生扩展 , 还能为你的网页游戏自动添加支付点:
下一步注册 网页钱包账户 然后在 game.project 文件的 Web Monetization 部分将支付点与钱包挂接:
已有项目
首先注册 网页钱包账户 然后手动在网页中加入支付点:
<meta name= "monetization" content= "YOUR_PAYMENT_POINTER" >
下一步将 网页支付原生扩展 作为 项目依赖库 加入. 打开 game.project 文件, 找到 Project 部分的 Dependencies 项 加入:
https://github.com/defold/extension-webmonetization/archive/master.zip
Defold 网页支付用法
在项目中加入扩展包和支付点之后就可以使用它了. 它的 API 包含两个部分:
检查玩家付款 (或者正在付款):
local monetized = webmonetization . is_monetized ()
if monetized then
print ( "The user has an active payment stream" )
end
设置监听器跟踪付款进度:
webmonetization . set_listener ( function ( self , event )
if event == webmonetization . EVENT_PENDING then
print ( "The user is trying to make a first payment" )
elseif event == webmonetization . EVENT_START then
print ( "The user has started paying" )
elseif event == webmonetization . EVENT_PROGRESS then
print ( "The user is still paying" )
elseif event == webmonetization . EVENT_STOP then
print ( "The user has stopped paying" )
end
end )
最佳实践
为付费玩家提供值钱的内容. 不同游戏类型有所不同. 比如:
如果游戏包含广告还可以考虑为付费玩家去掉广告