How implement Parallax screen in SuperJUmper Game? - android

Please any one assist me for implement parallax screen in super jumper game because I unnable to implement that. I have seen ParallaxTest.java
of your code but I can't Implement it. I same code in one class(ParallaxTest.java) and write only parallaxCamera class and in WorldRenderer I implement as but produce null pointer exception.
code:
public void renderBackground()
{
// background layer, no parallax, centered around origin
bath1.setProjectionMatrix(ParallaxCam.calculateParallaxMatrix(1, 1));
bath1.disableBlending();
bath1.begin();
bath1.draw(Assets.mainbackgroundRegion,ParallaxCam.position.x - FRUSTUM_WIDTH / 2, ParallaxCam.position.y - FRUSTUM_HEIGHT/2, FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
bath1.end();
in renderer---
if(ParallaxCam.position.y<FRUSTUM_HEIGHT)
{
ParallaxCam.position.y=FRUSTUM_HEIGHT;
//updateCamera = true;
}
And in constructr of WorldRendere--
this.ParallaxCam = new MyParallaxTest().new ParallaxCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
mcontroller = new OrthoCamController(this.ParallaxCam);
Gdx.input.setInputProcessor(mcontroller);
}

for this see this URL complete implementation is here
http://www.badlogicgames.com/forum/viewtopic.php?f=17&t=1795

Related

How to perform scroll in android native app with javascript

I am using appium and webdriverIO to automate android native app. I need to perform scroll down and i have used
ele.scrollIntoView(true) //this returns not yet implemented error
is there any other way to scroll down?
I don't used java script to scroll down. but I have already given a detail answer with different approach (by some text, element and screen size). Please have a look on it.
How to reach the end of a scroll bar in appium?
Hope it will help.
I have find a way to perform swipe down by calling JsonWireProtocol api directly from my code.
https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
here is my code
module.exports.scrollAndroid = function (ele) {
console.log('driver.sessionID = ', driver.sessionId);
while (!$(ele).isDisplayed()) { . //$(ele)=$(//xpath or any other attribute)
this.scrollAPICall();
driver.pause(3000);
}
};
module.exports.scrollAPICall = function () {
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
console.log("result status >> ", this.status);
console.log("result text >> ", this.responseText);
};
url1 = `http://127.0.0.1:4723/wd/hub/session/${driver.sessionId}/touch/flick`;
xhttp.open('POST', url1);
console.log("URL >> ", url1)
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.setRequestHeader("charset", "UTF-8");
xhttp.send(JSON.stringify({
xspeed: 10,
yspeed: -100,
}));
if you want to scroll up then give yspeed as + value. ex:100
You can achieve a scroll down by performing a Screen Swipe Up action. Implementation of swipe class can be found from Boilerplate project. The Gestures.js class has all required functions. Here is the link to class
Please keep in mind that the swipe is performed based on the percentage. Once you implement this Gestures class you can then use it like below:
while(!element.isDisplayed()) {
Gestures.swipeUp(0.5)
}

Photon objects not syncing - Unity

I am working on a multlayer third person game and I am using motion controller for animations and photon for network manager.I ahve a problem: when I connect and join the room the other players don't move on others player screen. They move only on their devices. Here is what I deactivated:
using UnityEngine;
using com.ootii.Input;
using com.ootii.Actors;
using com.ootii.Actors.AnimationControllers;
public class netView : Photon.MonoBehaviour {
public Camera cam;
public UnityInputSource uis;
public GameObject canvas;
public ActorController ac;
public MotionController mc;
// Use this for initialization
void Start () {
if (photonView.isMine) {
cam.enabled = true;
uis._IsEnabled = true;
canvas.active = true;
ac.enabled = true;
mc.enabled = true;
} else {
cam.enabled = false;
uis._IsEnabled = false;
canvas.active = false;
ac.enabled = false;
mc.enabled = false;
}
}
}
Here is a video: https://youtu.be/mOaAejsVX04 . In it i am playing in editor and on my phone. In my device I move around and the editor player does not move. Also in editor, the player from the device just stays there, doesn't move while on phone is moveing around.
For input I am using CrossPlatformManager class. How can I repair it?
In your case I think the problem is that you don't synchronize the transform to begin with. You need either a PhotonTransformView Component attached to your network object, with a photonView observing that PhotonTransformView, or inside your network behaviour manually writing and reading to that network object stream.
I strongly encourage you do go through the basic tutorial which will show you all the above technique step by step:
https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/player-networking#trans_sync
https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/player-networking#beams
it doesn't matter the input technique you use, what matters is the synchronization of the transform.

Android, Dronekit

I am develop an application for Rover to management by joystick. I need to create remote control to set direction of moving rover (left, right, forward, back). I'm trying to realize it by following code:
ControlApi.getApi(mDrone).enableManualControl(true, new ControlApi.ManualControlStateListener() {
#Override
public void onManualControlToggled(boolean b) {
}
});
ControlApi.getApi(mDrone).manualControl(0, -0.5f, 0, new AbstractCommandListener() {
#Override
public void onSuccess() {
}
#Override
public void onError(int i) {
}
#Override
public void onTimeout() {
}
});
But I'm getting an error 3 in onError block. Also before that I can't enable manual control it always return false. Can someone tell me what I'm doing wrong, or maybe guide me to the right way?
I would realy apriciate if someone can help me. Regards!
UPDATED
Still no result
Now I'm trying to use
MavLinkCommands.sendManualControl(drone, x, y, z, r, button, new ICommandListener(){...});
But can't run this method because drone is null.
I generate it like this:
MavLinkDroneManager mavLinkDroneManager =
new MavLinkDroneManager(mContext, mConnectionParameter, mHandler);
MavLinkDrone drone = mavLinkDroneManager.getDrone();
and method getDrone always return null.
SOLVED
If someone will encounter a similar problem, then the solution is quite simple. In total, you need to read the python documentation in more detail :)
All you need to do is override the channels using MAVLink command msg_rc_channels_override(); and the code with the solution will look like this:
VehicleApi.getApi(mDrone).setVehicleMode(VehicleMode.ROVER_MANUAL); //be sure the vehicle is in manual mode
VehicleApi.getApi(mDrone).arm(true); // and arm need to be true
by default chanel 1 is left-right, chanel 3 is forward-back.
If it does not work, check on the drones in which channels they are connected.
To move vehicle left set chanel 1 to 2000, right - 1000;
To move forward set chanel 3 - 2000, bacck - 1000;
I tested it on ArduRover but I think it should work with ArduPilot and ArduCopter.
msg_rc_channels_override rc_override = new msg_rc_channels_override();
rc_override.chan1_raw = 1000 //right; 2000 //left
rc_override.chan3_raw = 1000 //back; 2000 //forward
rc_override.target_system = 0;
rc_override.target_component = 0;
ExperimentalApi.getApi(mDrone).sendMavlinkMessage(new MavlinkMessageWrapper(rc_override));
For more instruction check this link

CharacterController.SimpleMove not working on Daydream View

I am trying to use a LookToWalk script in my Unity VR app that should run on my Daydream View. In the "Game" Mode to preview the changes everything works as expected (I configured the script to run forward once the user camera faces 30.0 degrees downwards or more.
However when I try to build the daydream app and install it on my Google Pixel the CharacterController.SimpleMove doesn't seem to work any more.
The logs were showing that the 30.0 degree stuff was triggered as expected but no movement was seen on the daydream.
Do you know why this could be happening? Seems really strange that it runs on the "emulator" but not the 'real' device.
using UnityEngine;
using System.Collections;
public class GVRLookWalk : MonoBehaviour {
public Transform vrCamera;
public float toggleAngle = 30.0f;
public float speed = 3.0f;
private bool shouldWalk;
private CharacterController cc;
// Use this for initialization
void Start () {
cc = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update () {
if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f){
shouldWalk = true;
} else {
shouldWalk = false;
}
if (shouldWalk) {
Vector3 forward = vrCamera.TransformDirection (Vector3.forward);
cc.SimpleMove (forward * speed);
}
}
Is the Camera a child of another transform? You cannot move the camera directly. "you cannot move the camera directly in Unity. Instead, the camera must be a child of another GameObject, and changes to the position and rotation must be applied to the parent’s Transform."
https://unity3d.com/learn/tutorials/topics/virtual-reality/movement-vr

Using if/if else/else statements for collision detection. How to improve?

I am currently developing a game in AndEngine and I have set up my collision detection with the enemies by checking each car against every individaul index of the enemy array as for some reason, a for loop does not work. This is extremely inconvinient as not only does it make increasing and decreasing enemies a chore, but it looks awful! It looks something like this:
if (rManager.getInstance().iceArray[0].getIceSprite().collidesWith(rManager.getInstance().carArray[r].getCarSprite()))
{
rManager.getInstance().carArray[r].setCarSpeed(1f);
} else if (rManager.getInstance().iceArray[1].getIceSprite().collidesWith(rManager.getInstance().carArray[r].getCarSprite())) {
rManager.getInstance().carArray[r].setCarSpeed(1f);
} else if (rManager.getInstance().iceBergArray[0].getIceBergSprite().collidesWith(rManager.getInstance().carArray[r].getCarSprite())) {
rManager.getInstance().carArray[r].setCarSpeed(0f);
} else {
rManager.getInstance().carArray[r].setCarSpeed(0.5f);
}
The for loop I tried was like this with [r] being every car of the car array, but it doesn't seem to do anything.
for (int h = 0; h < rManager.getInstance().snowArray.length; h++)
{
if (rManager.getInstance().snowArray[h].getSnowSprite().collidesWith(rManager.getInstance().carArray[r].getCarSprite())) {
String temp = rManager.getInstance().carArray[r].toString();
Log.e("SNOW", "SNOWWWWW!" + rManager.getInstance().snowArray[h].toString());
rManager.getInstance().carArray[r].setCarSpeed(0.2f);
}
}
Thanks!!
You should use factory pattern or strategy pattern to remove out the if else.
Please see the link below to take reference.
http://www.cumps.be/nl/blog/read/design-patterns-strategy-pattern
or Strategy Pattern with no 'switch' statements?
EDIT :
Base on your code, the startegy pattern should implement follow pesudo code below. I have made some of assumption base on your code already posted above.
You will create a dictionary contains logics and appropriate action as below:
Dictionary<Func<RManager, int, bool>, Action<Car>>
ruleUpdates =
new Dictionary<Func<RManager, int, bool>, Action<Car>>();
Each Func<Ice, Car, bool> you should implement like this
private bool ZeroElementEqualIcePrite(RManager rManager, int r)
{
return rManager.getInstance().iceArray[0].collidesWith(rManager.getInstance().carArray[r].getCarSprite());
}
and Action should implement as below:
public static void DoUpdateOneLevel(Car car)
{
car.setCarSpeed(1f);
}
From there we can implement similar with all of logics following your code with the same way.
You can initialize the dictionary following below
ruleUpdates.Add(FirstElementEqualIcePrite, DoUpdateOneLevel);
ruleUpdates.Add(SecondElementEqualIcePrite, DoUpdateOneLevel);
ruleUpdates.Add(FirstElementEqualIceBergPrite, DoUpdateZeroSpeed);
ruleUpdates.Add(SecondElementEqualIceBergPrite, DoUpdateZeroSpeed);
After that you just loop go through each key of executionList as below.
foreach (KeyValuePair<Func<RManager, int, bool>, Action<Car>>
ruleUpdate in ruleUpdates)
{
if (ruleUpdate.Key.Invoke(rManager, r))
{
ruleUpdate.Value.Invoke(rManager.getInstance().carArray[r]);
break;
}
}
Hope this help. Following the strategy your code will clean and easy to changed does not care much about if / then / else logic as well. You can easy extent it in future.

Categories

Resources