So I'm making a game with Haxe and Haxepunk. Fine. Except that when I export to C++, nothing is rendering! I posted this previously on the Haxepunk boards, so more info can be found here. Here's an excerpt from the Haxepunk thread;
I can still compile it just fine, but nothing in the game is actually rendering except for the background color I defined. The console still works and renders fine, though. The HaxePunk console tells me Atlases using BitmapData will not be managed.
I'm using Ash's component-entity system, and I'm not using Haxe's Entities. The relevant objects have a Visible component attached to them, which looks like this;
package game.component;
import com.haxepunk.Graphic;
import com.haxepunk.graphics.Image;
class Visible {
public var image(default, default) : Graphic;
public function new() {
this.image = Image.createRect(16, 16, 0xFF0000);
}
}
And this is the associated rendering system;
package game.system;
import ash.core.Engine;
import ash.core.Entity;
import ash.core.System;
import ash.tools.ListIteratingSystem;
import com.haxepunk.HXP;
import Constants;
import game.component.Positionable;
import game.component.Visible;
import game.node.RenderNode;
class RenderingSystem extends ListIteratingSystem<RenderNode> {
public function new() {
super(RenderNode, this.updateNode);
}
private function updateNode(node:RenderNode, time:Float) : Void {
node.renderable.image.render(HXP.buffer, node.position.position, Constants.ORIGIN);
}
}
Any tips?
If you are using buffer rendering in C++ you'll need to set the render mode inside the constructor. This is because the Engine constructor is the only place a screen buffer is created. Unfortunately the API docs don't clearly explain this.
class Main extends Engine
{
public function new()
{
super(0, 0, 60, false, RenderMode.BUFFER);
}
}
Related
I am having an issue trying to load the most basic custom mapping in React Native Web. The custom styles are loading just fine in the App, but not Web. Using the latest version with the babel loader hack as proposed here. I am using the default mapping as proposed in the UI Kitten docs for v5.x
My code looks like this:
import * as eva from '#eva-design/eva'
import * as mapping from '../styles/mapping.json'
import { myTheme } from '../styles/light-theme'
export default function App(): React.ReactElement {
return <>
<ApplicationProvider {...eva} theme={myTheme} customMapping={mapping}>
...
</ApplicationProvider>
</>
}
I tried replicating with a blank repo and it was working fine, so one line at a time I figured out that my import was not correct (not readable by babel?).
Instead of:
import * as mapping from '../styles/mapping.json'
Should be:
import {default as mapping} from '../styles/mapping.json'
The correct way is suggested in the UIKitten docs, so I don't think it will happen to many, but may help others as it's not an obvious thing if someone is working with the App emulator for the most time and not checking the Web until later.
This is the way I use the custom mapping with ts file: custom-mapping.ts
export const customMapping: any = {
components: {
CircleButton: {
meta:{...},
appearances: {...}
}
}
}
and import it like this:
...
import {customMapping} from '../custom-mapping';
<ApplicationProvider
...
customMapping={{...eva.mapping, ...customMapping}}
>
{children}
</ApplicationProvider>
I cannot find any suitable example on how to inject an app.context object into a Loopback 4 controller being in a separate file
This inline example from the documentation works fine
import {inject} from '#loopback/context';
import {Application} from '#loopback/core';
const app = new Application();
app.bind('defaultName').to('John');
export class HelloController {
constructor(#inject('defaultName') private name: string) {}
greet(name?: string) {
return `Hello ${name || this.name}`;
}
}
but I cannot find a way to obtain the same having my controller in a separate file.
I am trying to do something like this:
export class PingController {
constructor(#inject(app.name) private name: string)
app.name being a simple binding in my app-context.
Solution was quite simple.
Since all context values on app level is available throughout the application, no reference to app is required.
I just needed to replace (app.name) with ('name') in the constructor injection.
We recently moved from Play Framework 2.1 to 2.3 and some unit test stops working.
In this particular unit test, I'm using an object that extends Model from ebean. I make sure not to use any function from ebean (like find(), save() or update()).
Unfortunately, just by creating my object, I get an exception because it try to initiate the Model.Finder member, which I'm pretty sure it wasn't doing before the migration. How can I overcome this?
My setUp function that throw exception on the new call.
#Before
public void setUp() throws Exception {
SignageScheduleEntry allTheTimeSchedule = new SignageScheduleEntry();
}
My object itself, it fails on the new Model.Finder when debugging the unit test:
public static Model.Finder<Long,SignageScheduleEntry> find = new Model.Finder<>(Long.class, SignageScheduleEntry.class);
public SignageScheduleEntry() throws InvalidPeriodException {
....
}
In brief, I want to use my object without the ebean crap in my unit test like any object in any unit test. How can I achieve this?
Thanks!
As shown here:https://github.com/jamesward/play2torial/blob/master/JAVA.md#create-a-model
You will need to create a "fakeApplication" like so:
import org.junit.Test;
import static play.test.Helpers.fakeApplication;
import static play.test.Helpers.running;
import static org.fest.assertions.Assertions.assertThat;
import models.Task;
public class TaskTest {
#Test
public void create() {
running(fakeApplication(), new Runnable() {
public void run() {
Task task = new Task();
task.contents = "Write a test";
task.save();
assertThat(task.id).isNotNull();
}
});
}
}
If that doesn't work, or if that's not what you're looking for, another approach is more complex and convoluted from the Play Java docs:
https://www.playframework.com/documentation/2.3.x/JavaTest#Unit-testing-models
You basically have to create a wrapper for the Model, and mock out the wrapper in the unit tests.
I'm trying to write a REST Api class in swift and test it. I was attempting to follow the methodology in: how to test asynchronous methods Swift but I seem to have run into an issue.
Client/RestInterface.swift
import Foundation
protocol RestSearchProtocol {
func didRecieveResponse(results: NSDictionary)
}
public class RestInterface : NSObject {
// lots of code we don't care about ...
}
ClientTests/RestInterfaceTests.swift
import UIKit
import XCTest
import Client
class RestInterfaceTests: XCTestCase, RestSearchProtocol {
// ... rest of the test file
I'm getting an undeclared type error.
Any suggestions as how to make this work?
As a side note - if i take the RestInterfaceTests class and put it at the end of RestInterface.swift it seems to find the protocol, but XCTestCase is now undeclared
It appears i was missing the public identifier:
import Foundation
public protocol RestSearchProtocol {
func didRecieveResponse(results: NSDictionary)
}
public class RestInterface : NSObject {
// lots of code we don't care about ...
}
has solved the problem
use
#testable import Client
You don't need to set your types as public anymore!
I'm trying to make a HelloWorld application for Google Glass by using the GDK provided.
This is the entire codestack, I'm trying to work out the way to program this. Compiling doesn't give any errors but running it does.
package leagueMatch;
import com.google.android.glass.timeline.LiveCard;
import com.google.android.glass.timeline.TimelineManager;
import com.luisdelarosa.helloglass.R;
import android.os.Bundle;
import android.os.IBinder;
import android.app.Activity;
import android.app.Service;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.widget.RemoteViews;
public class MainActivity extends Service {
String blue_team, purple_team, mvp, casters;
int blue_kills, purple_kills;
private LiveCard mLiveCard;
private TimelineManager mTimelineManager;
private RemoteViews mViews;
private static final String TAG = "LeagueMatchInfo";
private static final String LIVE_CARD_ID = "leaguematch";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate();
//mTimelineManager = xxxxxx;
mViews.setTextViewText(blue_kills, "Lol, Let's see if this works");
mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
mLiveCard.setViews(mViews);
mLiveCard.setDirectRenderingEnabled(true);
mLiveCard.publish(LiveCard.PublishMode.SILENT);
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return true;
}
#Override
public IBinder onBind(Intent intent) {
return null;
}
}
Isn't this supposed to launch a card which says "Lol, let's see if this works?"
I created a Hello World project on GitHub.
Start the app by saying "ok glass, hello world" or click on Hello World card shown on the timeline.
The live card has an option menu with two choices:
Say Hi
Close app
Please mark as answer if this helps.
It looks like you're conflating concepts from activities and services. You're right to be using a service to maintain the LiveCard. But you should override the onStartCommand method to publish the card when the service is launched. Please see the source code for the Compass, Stopwatch, and Timer for more examples.