在提供的屏幕截图中,红色箭头和十字架仅用于演示目的,不在游戏中.我希望宇宙飞船的精灵能够面对射击球的方向.
这是我目前的触摸位置代码
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
for touch in touches {
let location = touch.locationInNode(self)
var bullet = SKSpriteNode(imageNamed: "bullet")
bullet.position = cannon.position
bullet.size = CGSize(width: 35, height: 35)
//physics
bullet.physicsBody = SKPhysicsBody(circleOfRadius: bullet.size.width/2)
bullet.physicsBody?.categoryBitMask = PhysicsCategory.bullet
bullet.physicsBody?.collisionBitMask = PhysicsCategory.enemy
bullet.physicsBody?.contactTestBitMask = PhysicsCategory.enemy
bullet.name = "bullet"
bullet.physicsBody?.affectedByGravity = false
self.addChild(bullet)
var dx = CGFloat(location.x - cannon.position.x)
var dy = CGFloat(location.y - cannon.position.y)
let magnitude = sqrt(dx * dx …Run Code Online (Sandbox Code Playgroud) 这是我的第一个Android应用程序,我正在从iOS开发过渡.我正在尝试改变其他活动.但是,我的新空活动需要几秒钟(大约3秒)才能显示.
这是我要转发到新活动的代码:
public void openStats(View v) {
startActivity(new Intent(MainActivity.this, StatsActivity.class));
}
Run Code Online (Sandbox Code Playgroud)
这是我对我的新活动的创建:
public class StatsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.stats_page);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么这么长时间?我也正在测试三星Galaxy S5.
这是打开新活动时的日志:
D/ViewRootImpl: ViewPostImeInputStage processPointer 0
D/ViewRootImpl: ViewPostImeInputStage processPointer 1
I/Timeline: Timeline: Activity_launch_request id:com.example.NAME.reflexmath time:53311650
W/ResourcesManager: getTopLevelResources:/data/app/APPNAME2/base.apk / 1.0 running in APPNAME rsrc of package null
D/SecWifiDisplayUtil: Metadata value : none
D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{a1db7f7 I.E...... R.....ID 0,0-0,0}
D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, …Run Code Online (Sandbox Code Playgroud) 当用户调用restorePurchases()时,即使他们不拥有它,也会恢复非耗材com.premium.以下是负责恢复购买和购买IAP的功能.这只是非耗材IAP的问题.购买没有问题.如果用户尝试购买他们已经拥有的IAP,则只需恢复.感谢您关注此事.
func restorePurchases() {
SKPaymentQueue.default().add(self)
SKPaymentQueue.default().restoreCompletedTransactions()
}
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
print("transactions restored")
for transaction in queue.transactions {
let t: SKPaymentTransaction = transaction
let prodID = t.payment.productIdentifier as String
print("starting restoring")
switch prodID {
case "com.premium":
print("restoring ads")
removeAds()
case "com.cash":
print("we dont restore coins")
case "com.level":
print("we dont restore levels")
default:
print("can't restore")
}
}
Run Code Online (Sandbox Code Playgroud)
这也是我的支付队列.
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("add paymnet")
for transaction:AnyObject in transactions {
let trans = transaction as! SKPaymentTransaction
print(trans.error) …Run Code Online (Sandbox Code Playgroud)