using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateTank : MonoBehaviour {
public Transform Selftransform;
private Vector3 _force;
private int rotate = 1;
Rigidbody rb;
// Use this for initialization
void Start () {
rb = this.gameObject.GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
Selftransform.position += _force;
if (rotate == 1)
{
transform.Rotate(0, 0, 2);
rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationX;
rb.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationY;
}
if (Input.GetKey(KeyCode.W))
{
rotate = 0;
_force += (Selftransform.up * Time.deltaTime) * 0.1f;
rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationZ;
}
else
{
_force = Vector3.Lerp(_force, Vector3.zero, 10);
rotate = 1;
}
}
}
local widget = require("widget")
_W = display.contentWidth;
_H = display.contentHeight;
local background = display.newImageRect("sprites/background.jpg", _W, _H);
background.x = _W/2;
background.y = _H/2;
local physics = require("physics")
physics.start()
physics.setGravity(0, 0)
local sheetOptions =
{
frames =
{
{
x = 0,
y = 0;
width = 433;
height = 425;
}
}
}
local objectSheet = graphics.newImageSheet("sprites/bluetank1.png", sheetOptions)
local backGroup = display.newGroup()
local mainGroup = display.newGroup()
local uiGroup = display.newGroup()
local tank1
tank1 = display.newImageRect(mainGroup, objectSheet, 1, 40, 37)
tank1.x = 200
tank1.y = 400
physics.addBody(tank1, "dynamic")
local rotate = 0
function endlessRolling(tank1)
tank1.rotation = 0
if rotate == 0 then
transition.to(tank1, {time=2000, rotation = 360, onComplete = endlessRolling})
end
end
endlessRolling(tank1)
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<header class="page-header">
<div id="menu">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
<nav class="page-header__menu">
<a href="https://"><h1>_a_g</h1></a>
</nav>
<div class="page-header__logout">
<a href="/">
<img src="https://svgshare.com/i/Cqb.svg" alt="" height="22"/>
</a>
</div>
</header>
<div id="main">
<ul>
<li>Курсы</li>
<li>Новости</li>
<li>Вопросы</li>
<li>Блог</li>
<li>О нас</li>
</ul>
</div>
<div id="main1">
r
</div>
</body>
</html>
html,
body {
margin:0;
padding:0;
background-color:#dcdcdc;
}
header {
background-color:white;
width:100%;
height:50px;
position:fixed;
}
.page-header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
$(function(){
$('#menu').on('click', function(){
$('#main').toggleClass('menu-open');
$('#main1').toggleClass('menu-open1');
});
});
$(function(){
$('#main1').on('click', function(){
$('#main').toggleClass('menu-close');
$('#main1').toggleClass('menu-close1');
});
});